回复 7# mxkor
我来回答你的问题,,,
1: 我不是用NETSH 做的IP修改(某些软件发现IP变化就会注销,而用这个命令修改的话就会,我用的是注册表)
2:下面这个函数获取到的网卡信息Func _InetIsOffline()
Return DllCall("url.dll","bool","InetIsOffline","DWORD",0)
EndFunc
;======================================================
;
; 函数名称: _NetworkAdapterInfo()
; 详细信息: 获得网卡信息
; 返回值说明:
; 以二维数组方式返回.例如 $info=_NetworkAdapterInfo()
; $info[0][0]=网卡数量
; $info[1][0]第一块网卡的标志1
; $info[2][0]第二块网卡的标志2
; $info[1][1]第一块网卡的网卡名称
; $info[2][1]第二块网卡的网卡名称
; $info[1][2]第一块网卡的默认网关
; $info[1][3]第一块网卡的DNS主机名称(本机名称)
; $info[1][4]第一块网卡的IP地址
; $info[1][5]第一块网卡的主DNS
; $info[1][6]第一块网卡的次DNS
; $info[1][7]第一块网卡的子网掩码
; $info[1][8]第一块网卡的MAC地址
; $info[1][9]第一块网卡的连接名称
; 注意,此UDF不会获取已经禁用的网卡。
; 如果有需要,请删除' WHERE IPEnabled != 0'和' WHERE NetConnectionStatus >0'
; 作者: thesnow(rundll32@126.com)
;
;======================================================
Func _NetworkAdapterInfo()
Local $colItems = ""
Local $objWMIService
Local $NetworkAdapterID = 0
Local $NetworkAdapterName = ""
Local $NetworkAdapterGateway = ""
Local $NetworkAdapterHostName = ""
Local $NetworkAdapterIPaddress = ""
Local $NetworkAdapterDNS1 = ""
Local $NetworkAdapterDNS2 = ""
Local $NetworkAdapterSubnet = ""
Local $NetworkAdapterMAC = ""
Local $NetworkAdapterNetConnectionID = ""
Local $NetworkAdapterInfo[10][10] ;最高10块网卡.
$NetworkAdapterInfo[0][0] = 0
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", 0x10 + 0x20)
$colItem2 = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus >0', "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
For $objItem In $colItems
$NetworkAdapterName = $objItem.Description
$NetworkAdapterGateway = $objItem.DefaultIPGateway(0)
$NetworkAdapterHostName = $objItem.DNSHostName
$NetworkAdapterIPaddress = $objItem.IPAddress(0)
$NetworkAdapterDNS1 = $objItem.DNSServerSearchOrder(0)
$NetworkAdapterDNS2 = $objItem.DNSServerSearchOrder(1)
$NetworkAdapterSubnet = $objItem.IPSubnet(0)
$NetworkAdapterMAC = $objItem.MACAddress
$NetworkAdapterID += 1
$NetworkAdapterInfo[0][0] = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID][0] = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID][1] = $NetworkAdapterName
$NetworkAdapterInfo[$NetworkAdapterID][2] = $NetworkAdapterGateway
$NetworkAdapterInfo[$NetworkAdapterID][3] = $NetworkAdapterHostName
$NetworkAdapterInfo[$NetworkAdapterID][4] = $NetworkAdapterIPaddress
$NetworkAdapterInfo[$NetworkAdapterID][5] = $NetworkAdapterDNS1
$NetworkAdapterInfo[$NetworkAdapterID][6] = $NetworkAdapterDNS2
$NetworkAdapterInfo[$NetworkAdapterID][7] = $NetworkAdapterSubnet
$NetworkAdapterInfo[$NetworkAdapterID][8] = $NetworkAdapterMAC
Next
Else
Return $NetworkAdapterInfo
EndIf
If IsObj($colItem2) Then
$NetworkAdapterID = 0
For $objItem2s In $colItem2
$NetworkAdapterNetConnectionID = $objItem2s.NetConnectionID
$NetworkAdapterID += 1
$NetworkAdapterInfo[$NetworkAdapterID][9] = $NetworkAdapterNetConnectionID
Next
Return $NetworkAdapterInfo
Else
Return $NetworkAdapterInfo
EndIf
EndFunc ;==>_NetworkAdapterInfo
|