谁有纯VB源码更改IP地址的程序,请贴上来看了VC的在使用DHCPNotifyConfigChange了其中用到了指针调用函数我不知道在VB中怎么实现,哪位大侠能把实现方法说一下最好有范例程序

解决方案 »

  1.   

    什么叫纯VB源码,呵呵
    看到过用cmd指令做的
      

  2.   

    不要CMD的最好是使用API的
    比如DHCPNotifyConfigChange
    或者是更改注册表重启网卡的也行
      

  3.   

    The Code
    To use this script, type it into Notepad (with Word Wrap turned off) and save it with a .vbs extension as ChangeIP.vbs:Option ExplicitDim NetworkAdapter, AdapterConfiguration 'Objects
    Dim IPAddress, SubnetMask, Gateway, DNS 'String Arrays
    Dim RetVal 'IntegersFor Each NetworkAdapter In
    GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapter")
    If NetworkAdapter.AdapterType = "Ethernet 802.3" Then
    For Each AdapterConfiguration In GetObject("winmgmts:").InstancesOf
    ("Win32_NetworkAdapterConfiguration")
    If UCase(AdapterConfiguration.ServiceName) = UCase(NetworkAdapter.ServiceName) Then
    IPAddress = Array("192.168.0.10")
    SubnetMask = Array("255.255.255.0")
    Gateway = Array("192.168.0.1")
    DNS = Array("35.8.2.41")RetVal = AdapterConfiguration.EnableStatic(IPAddress, SubnetMask)
    If Not RetVal = 0 Then
    WScript.Echo "Failure assigning IP/Subnetmask."
    End If
    RetVal = AdapterConfiguration.SetGateways(Gateway)
    If Not RetVal = 0 Then
    WScript.Echo "Failure assigning Gateway."
    End If
    RetVal = AdapterConfiguration.SetDnsServerSearchOrder(DNS)
    If Not RetVal = 0 Then
    WScript.Echo "Failure assinging DNS search order."
    End If
    End If
    Next
    End If
    Next
     
    不知道有没有什么用