|
本帖最后由 yikang8888 于 2010-12-22 15:49 编辑
哪位高手指点一下,下面的代码,,在出现多个设备时会弹出对话框让选择,但我不想在选择的里面出现
ID为{000000000000000000000}的这一项,请问是那边有问题,感谢
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
MsgBox(0, "当前选择网卡索引", '[' & NICIndex() & ']')
Exit
Func NICIndex()
Local $test, $iNICIndex
$test=_UpCmpLanNameIDInfo()
If $test[0][0] = 0 Then
MsgBox(0x10, "错误", "获取网络适配器设置失败,请检查网卡驱动。")
Exit 2
ElseIf $test[0][0] = 1 Then
$iNICIndex = $test[1][0]
Else
; 创建“网卡选择”窗口
Local $hNICWnd, $hOKButton, $hIfTable
$hNICWnd = GUICreate("测试" & " - 网卡选择", 404, 118)
GUICtrlCreateLabel("检测到本机安装有多个网络适配器,请选择用于更新的网卡。", 16, 16, 340, 24)
$hIfTable = GUICtrlCreateCombo("", 16, 48, 372, 12 * $test[0][0], BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
For $i = 1 To $test[0][0]
GUICtrlSetData(-1, $test[$i][0] & ". " & $test[$i][1])
Next
GUICtrlSetData(-1, $test[1][0] & ". " & $test[1][1])
$hOKButton = GUICtrlCreateButton("确定(&O)", 165, 80, 76, 22, $BS_DEFPUSHBUTTON)
; 窗口事件
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $hOKButton, $GUI_EVENT_CLOSE
$iNICIndex = GUICtrlRead($hIfTable)
ExitLoop
EndSwitch
WEnd
GUIDelete($hNICWnd)
$iNICIndex = StringLeft($iNICIndex, StringInStr($iNICIndex, ".") - 1)
EndIf
EndFunc
Func _UpCmpLanNameIDInfo()
Local $colItems = ""
Local $strComputer = "localhost"
Local $objWMIService
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $UpCmprAdapterID = 0
Local $UpCmprAdapterHostName = ""
Local $UpCmpLanNameID[10][2]
$UpCmpLanNameID[0][0] = 0
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_TSNetworkAdapterListSetting", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
$UpCmpLan = $objItem.Description
$UpCmpID = $objItem.NetworkAdapterID
$UpCmprAdapterID += 1
$UpCmpLanNameID[0][0] = $UpCmprAdapterID
$UpCmpLanNameID[$UpCmprAdapterID][0] = $UpCmpLan
$UpCmpLanNameID[$UpCmprAdapterID][1] = $UpCmpID
Next
EndIf
Return $UpCmpLanNameID
EndFunc ;==>_UpCmpLanNameIDInfo |
|