| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 723 人关注过本帖
标题:[求助]如果用vb编写修改IP的工具
只看楼主 加入收藏
zaq3276675
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-8-11
收藏
 问题点数:0 回复次数:1 
[求助]如果用vb编写修改IP的工具
如果用vb编写修改IP的工具,希望能把源码传上来,谢谢!
搜索更多相关主题的帖子: 工具 编写 
2007-01-30 16:41
清澂居士
Rank: 6Rank: 6
等 级:贵宾
威 望:28
帖 子:1237
专家分:7
注 册:2006-12-19
收藏
得分:0 

是不是脩改本機上的IP呢???


Function ChangeIP(IP As String, NM As String, GW As String, MDNS As String, SDNS As String) As String
Dim strComputer, objWMIService, colNetAdapters, strIPAddress, strSubnetMask
Dim strGateway, strGatewaymetric, strDNS, objNetAdapter, errEnable, errGateways, errDNS

strComputer = "."

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")

strIPAddress = Array(IP) 'IP地址
strSubnetMask = Array(NM) '子网
strGateway = Array(GW) 'Gateways
strDNS = Array(MDNS, SDNS) 'MAIN DNS AND SECOND DNS
strGatewaymetric = Array(1)

For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
errDNS = objNetAdapter.SetDNSServerSearchOrder(strDNS)

If errEnable = 0 And errGateways = 0 And errDNS = 0 Then
ChangeIP = "成功"
Else
If errEnable = 0 Then
ChangeIP = "IP地址和子网成功, "
Else
ChangeIP = "IP地址或子网置 X, "
End If
If errGateways = 0 Then
ChangeIP = ChangeIP & "DEFAULT成功, "
Else
ChangeIP = ChangeIP & "DEFAULT X, "
End If
If errDNS = 0 Then
ChangeIP = ChangeIP & "DNS成功"
Else
ChangeIP = ChangeIP & "DNS X"
End If
End If
Next

End Function

Private Sub Command1_Click()
MsgBox ChangeIP(Winsock1.LocalIP, "255.255.255.0", "192.168.2.10", "192.168.2.10", "192.168.2.1")
End Sub

Private Sub Command2_Click()
MsgBox ChangeIP(Winsock1.LocalIP, "255.255.255.0", "192.168.2.1", "192.168.2.1", "192.168.2.10")
End Sub

Private Sub Form_Load()

If Winsock1.Index = "192.168.2.1" Then
Label2.Caption = "电信"
Else
Label2.Caption = "鉄通"
End If
End Sub


佛曰:\"前世的500次回眸才换来今生的一次擦肩而过\".我宁愿用来世的一次擦肩而过来换得今生的500次回眸.
2007-01-30 17:23
快速回复:[求助]如果用vb编写修改IP的工具
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024456 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved