看到例子都是几乎都是获取本机IP地址和MAC地址的,没留意到有相关的针对IP地址,提前其MAC地址的方法?
贴个例子是获取网关ip地址的:MsgBox(0,0,_Gateway())
Func _Gateway()
Dim $IPGateway
Dim $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
Dim $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
For $objItem In $colItems
$IPGateway = $objItem.DefaultIPGateway(0)
If StringInStr($IPGateway, ".") > 0 Then ExitLoop
Next
If StringRegExpReplace($IPGateway, '(\d+\.){12}', '') = "" Then
MsgBox ( 0 , "ERROR" , "无法获取本地网关,请检查网线是否连接且已通过认证" )
Else
Return StringRegExpReplace($IPGateway, '(\d+\.){12}', '')
EndIf
EndFunc
|