电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

vb实现IP设置


发布日期:2020/10/26
 

这些天总是带着笔记本在家/单位/客户等等几个地方跑来跑去的于是在各个地方上网都是要重新设置的有时候有线有时候无线昨天我终于爆发了再也受不了这么没有尽头的折磨了于是我又用vb写了一个简单的IP设置转换器(我已经上传地址

界面如下

其实利用vb修改ip地址是比较容易的我利用的就是wmi方式先是找出当前系统的所有网卡信息下面给出的是找出所有网卡MAC地址的例程Function GetMACaddress()

Dim tempBool As Boolean strComputer =

Set objWMIServiceGL = GetObject(winmgmts\\ & strComputer & \root\cimv

Set colNetAdaptersGL = objWMIServiceGLExecQuery(Select * from Win_NetworkAdapterConfiguration where(IPEnabled=TRUE)

For Each obj In objs

getMACAddress = getMACAddress & objmacaddress & vbCrLf & vbCrLf

Exit For 找第一个网卡就退出

Next obj End Function

然后根据所找到的各个网卡的进行信息(IPDNS等)更改Function ModifyIP() strComputer =

Set objWMIService = GetObject(winmgmts\\ & strComputer & \root\cimv

Set objSWbemObjectSet = objSWbemServicesExecQuery(Select * From Win_NetworkAdapterConfiguration Where Description= & ComboText &

For Each objNetAdapter In colNetAdapters sip = objNetAdapterIPaddress(

If OptionValue = True Then DHCP is enabled

objNetAdapterEnableDHCP

errDNS = objNetAdapterSetDNSServerSearchOrder()

Else strIPAddress = Array(TextText)

strSubnetMask = Array(TextText)

strGateway = Array(TextText)

strGatewaymetric = Array(

StrDns = Array(TextText TextText)

errEnable = objNetAdapterEnableStatic(strIPAddress strSubnetMask)

errGateways = objNetAdapterSetGateways(strGateway strGatewaymetric)

errDNS = objNetAdapterSetDNSServerSearchOrder(StrDns)

Exit For 只修改第一个网卡的设置

End If Next End Function

上一篇:从简单的例子理解泛型

下一篇:网站性能越来越差怎么办