2

Googleで検索すると、このコードが見つかりました。DNS サーバーを静的に変更したいだけです。静的 DNS と代替 DNS サーバーをここに配置する場所がわかりません。私を助けてください。ありがとう :)

Public Sub setDNS(ByVal NIC As String, ByVal DNS As String)
   Dim objMC As New ManagementClass("Win32_NetworkAdapterConfiguration")
   Dim objMOC As ManagementObjectCollection = objMC.GetInstances()

   For Each objMO As ManagementObject In objMOC
      If CBool(objMO("IPEnabled")) Then
         ' if you are using the System.Net.NetworkInformation.NetworkInterface you'll need to change this line to if (objMO["Caption"].ToString().Contains(NIC)) and pass in the Description property instead of the name 
         If objMO("Caption").Equals(NIC) Then
            Try
               Dim newDNS As ManagementBaseObject = objMO.GetMethodParameters("SetDNSServerSearchOrder")
               newDNS("DNSServerSearchOrder") = DNS.Split(","c)
               Dim setDNS As ManagementBaseObject = objMO.InvokeMethod("SetDNSServerSearchOrder", newDNS, Nothing)
            Catch generatedExceptionName As Exception
               Throw
            End Try
         End If
      End If
   Next
End Sub

どんなヘルプでも大歓迎です。前もって感謝します。

4

0 に答える 0