|
如题,在多网卡的状态下如何判断每个网卡的IP是手动指定还是DHCP分配的?论坛里有一哥们通过注册表的方式来搞,但我试了下有时候明明把IP改成手动的了,但注册表里那个enbaleDHCP的值还是1,也就是说通过下面的代码拿到的还是网卡的IP是DHCP分配的,各位还有没有好的方法?谢谢!
$i = 1
While 1
$reg = RegEnumKey ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards",$i)
If @error <> 0 Then ExitLoop
$networkcard = RegRead ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$reg,"ServiceName")
$name = RegRead ("HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\"&$reg,"Description")
$dhcpyn = RegRead ("HKLM\SYSTEM\ControlSet001\Services\Tcpip\Parameters\Interfaces\"&$networkcard,"EnableDHCP")
If $dhcpyn = 1 Then
MsgBox (0,"Test","网卡"&$name&"为自动获取IP")
ElseIf $dhcpyn = 0 Then
MsgBox (0,"Test","网卡"&$name&"为手动指定IP")
Else
MsgBox (0,"Test","你的电脑还怪耶 ")
EndIf
$i += 1
WEnd |
|