就是本地连接的“属性”,然后“TCP/IP”属性的那个设置IP的对话框,怎么调用?如果不能调用,怎么设置IP呢???

解决方案 »

  1.   

    用wmi可以轻松设置IP
    当然,也可以netsh(cmd 命令)
      

  2.   


    Function ModifyIP()
      
        strComputer = "."
     
       Set objWMIServiceGL = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     
       Set colNetAdapters = objWMIServiceGL.ExecQuery("Select * from Win32_NetworkAdapterConfiguration")
     
       
        For Each objNetAdapter In colNetAdapters        strIPAddress = Array("192.168.1.107") 'IP地址
     
            strSubnetMask = Array("255.255.255.0") '子网掩码
     
            errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
     
          Exit For '只修改第一个网卡的设置
        Next
    End Function以上能更改IP地址:以上代码段参考:
    http://www.qqread.com/vb/o415390.html
     Function ModifyIP() strComputer = "."
     
      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     
      Set objSWbemObjectSet = objSWbemServices.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where Description='" & Combo1.Text & "'")
     
      For Each objNetAdapter In colNetAdapters sip = objNetAdapter.IPaddress(0)
     
      If Option1.Value = True Then 'DHCP is enabled
     
      objNetAdapter.EnableDHCP
     
      errDNS = objNetAdapter.SetDNSServerSearchOrder()
     
      Else strIPAddress = Array(Text1.Text)
     
      strSubnetMask = Array(Text2.Text)
     
      strGateway = Array(Text3.Text)
     
      strGatewaymetric = Array(1)
     
      StrDns = Array(Text4.Text, Text5.Text)
     
      errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
     
      errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
     
      errDNS = objNetAdapter.SetDNSServerSearchOrder(StrDns)
     
      'Exit For '只修改第一个网卡的设置
     
      End If Next End Function