[帮个小忙]如何用VB调用系统中的设置IP的对话框?

Gutta 2008-08-26 08:56:56
就是本地连接的“属性”,然后“TCP/IP”属性的那个设置IP的对话框,怎么调用?

如果不能调用,怎么设置IP呢???
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
onhi 2008-08-29
  • 打赏
  • 举报
回复
楼上的可以看看
fvflove 2008-08-26
  • 打赏
  • 举报
回复

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



zzyong00 2008-08-26
  • 打赏
  • 举报
回复
用wmi可以轻松设置IP
当然,也可以netsh(cmd 命令)

1,502

社区成员

发帖
与我相关
我的任务
社区描述
VB 网络编程
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧