#include <GUIConstants.au3>
#include <Array.au3>
#Region ### START Koda GUI section ### Form=c:\documents and settings\cface\桌面\222.kxf
;Opt("TrayIconHide", 1)
Opt("TrayMenuMode", 1)
#include <GUIConstantsEx.au3>
Opt('MustDeclareVars', 1)
Dim $ret = "", $bt11, $nMsg, $input, $s, $s1, $ttt = 22, $i = 0, $wk1, $card[20], $setcard = ''
getipinfo()
Local $msg
GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered
GUICtrlCreateLabel("请选择网克使用网卡:", 10, 30)
For $i = 1 To $card[0]
$setcard &= $card[$i] & '|'
Next
$input = GUICtrlCreateCombo('请选择一块网卡', 10, 50, 380, 20) ; create first item
GUICtrlSetData($input, $setcard) ; add other item snd set a new default
$bt11 = GUICtrlCreateButton("测试", 100, 160, 50, 30)
GUISetState()
$s = GUICtrlRead($input)
While 1
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
Exit
Case $nMsg = $bt11
$s1 = GUICtrlRead($input)
MsgBox(64,"网卡检测:",$s1)
EndSelect
WEnd
Func getipinfo() ;获取本机网卡全部信息
Local $wbemFlagReturnImmediately, $wbemFlagForwardOnly, $deip, $demask, $dedns, $dedns2, $degete, $dename
Local $network, $strComputer, $objWMIService, $colItems, $Output, $strIPAddress, $strDNSServerSearchOrder, $strIPSubnet
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$colItems = ""
$strComputer = "localhost"
$Output = ""
$Output = $Output & "计 算 机:" & $strComputer & @CRLF
$Output = $Output & "==========================================" & @CRLF
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
Local $check2 = '', $check1 = '', $counter = 0
If IsObj($colItems) Then
For $objItem In $colItems
$Output = $Output & "网 卡: " & $objItem.Description & @CRLF
;$strDefaultIPGateway = $objItem.DefaultIPGateway(0)
$Output = $Output & "默认网关: " & $objItem.DefaultIPGateway(0) & @CRLF
$Output = $Output & "计算机名: " & $objItem.DNSHostName & @CRLF
$strIPAddress = $objItem.IPAddress(0)
$Output = $Output & "I P地址: " & $strIPAddress & @CRLF
$strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(0)
$Output = $Output & "默认 DNS: " & $strDNSServerSearchOrder & @CRLF
$strDNSServerSearchOrder = $objItem.DNSServerSearchOrder(1)
$Output = $Output & "备用 DNS: " & $strDNSServerSearchOrder & @CRLF
$strIPSubnet = $objItem.IPSubnet(0)
$Output = $Output & "子网掩码: " & $strIPSubnet & @CRLF
$Output = $Output & "M AC地址: " & $objItem.MACAddress & @CRLF
if Msgbox(1,"WMI获取的信息:",$Output) = 2 then ExitLoop
$Output = ""
$check1 = $objItem.MACAddress
If $check1 = $check2 Then
If $check1 = '' Then Return MsgBox(64, '', '无网上卡')
ExitLoop
EndIf
$check2 = $check1
$counter += 1
$card[0] += 1
$deip = $strIPAddress
$demask = $strIPSubnet
$dedns = $objItem.DNSServerSearchOrder(0)
$dedns2 = $objItem.DNSServerSearchOrder(1)
$degete = $objItem.DefaultIPGateway(0)
$dename = $objItem.DNSHostName
$card[$counter] = $objItem.Description & $counter
MsgBox(64, "netcardname", $strIPAddress)
Next
For $i = 1 To $counter
MsgBox(64, "card"&$i, $card[$i])
Next
EndIf
EndFunc ;==>getipinfo
测试了下,我单网卡,显示还是2块网卡。
[ 本帖最后由 番茄 于 2008-10-17 12:39 编辑 ] |