2016-04-06 24 views
0

Ben acemi kodlayıcısıyım, bu yüzden bu bilgili değilim. Lütfen aptalca sorularımla iyi ol. GetNIC() ve MakeStatic()Ad alanı Crossroads

GetNIC() System.Net.NetworkInformation ad kullanır: Yardımcı programı

İki VB.NET işlevleri var anahtarlama bir IP adresi yazıyorum. Mevcut IPv4 bağdaştırıcısını, IP, DGW, SM ve diğer bilgileri bulmak için çalışıyor.

MakeStatic(), System.Management ad alanını kullanır. Ben aynı bağdaştırıcıyı ve aynı bilgileri değiştirmek için GetNIC() gelen bilgileri nasıl kullanacağımı anlamaya çalışıyorum. IP'yi değiştirmek için kodumun bir pasajı. Daha önce hiç ManagementBaseObjects kullanmamıştım ve GetNIC() 'de bulduğum GUID ile eşleşen GUID'yi (veya bir şeyi) nasıl bulacağımı merak ediyordum.

  Dim objNewIP As ManagementBaseObject = Nothing 
      Dim objSetIP As ManagementBaseObject = Nothing 
      Dim objNewGate As ManagementBaseObject = Nothing 

      objNewIP = objMO.GetMethodParameters("EnableStatic") 
      objNewGate = objMO.GetMethodParameters("SetGateways") 

      'Set DefaultGateway 
      objNewGate("DefaultIPGateway") = New String() {Gateway} 
      objNewGate("GatewayCostMetric") = New Integer() {1} 

      'Set IPAddress and Subnet Mask 
      objNewIP("IPAddress") = New String() {IPAddress} 
      objNewIP("SubnetMask") = New String() {SubnetMask} 

      objSetIP = objMO.InvokeMethod("EnableStatic", objNewIP, Nothing) 
      objSetIP = objMO.InvokeMethod("SetGateways", objNewGate, Nothing) 

Temelde ben vuruyorum:

If objMO.<<something>> = NICguid then 
    <<<Do the above code>> 
End IF 

cevap