我这只有 ac97集成声卡 可以显示
莫非hdaudio集成声卡 不在root\cimv2里
开个源吧以前 写过歌读取注册表硬件的
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ListviewConstants.au3>
#include <EditConstants.au3>
#include <GuiListView.au3>
;定义全局常量
;------------------------------------------------------------------------------
;PCI设备注册表路径
Global Const $PciPath = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\PCI"
;HD声卡注册表路径
Global Const $HDAudioPath = "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\HDAUDIO"
Global Const $Unkouw = "未知设备"
Global Const $VGA = "显卡"
Global Const $NET = "网卡"
Global Const $SND = "声卡"
Global Const $OTHER = "其它"
;------------------------------------------------------------------------------
;定义全局变量
;------------------------------------------------------------------------------
;存放PCI/HDAUDIO下,子键ID
Global $IDList[100]
;子键ID的子键
Global $KeyList[100]
;设备类型
Global $Class[100]
;设备描述
Global $DeviceDesc[100]
;硬件ID
Global $HardwareID[100]
;厂商代码
Global $Vendor[100]
;------------------------------------------------------------------------------
Local $window
Local $listview
Local $labletype
Local $lablehard
Local $lable
Local $edit
Local $button
Local $item[11]
Local $i
Local $width = 700
Local $hight = 500
Local $left = (@DesktopWidth - $width)/2
Local $top = (@DesktopHeight - $hight)/2
Local $msg
$window = GUICreate("硬件ID提取工具", $width, $hight,$left, $top,$WS_MINIMIZEBOX+$WS_SIZEBOX)
GUICtrlSetFont($window,12)
$listview = GUICtrlCreateListView("类型|描述|硬件ID",10,40,680,180,-1,$LVS_EX_GRIDLINES+$LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($listview ,0,80)
_GUICtrlListView_SetColumnWidth($listview ,1,230)
_GUICtrlListView_SetColumnWidth($listview ,2,350)
GUICtrlSetFont($listview,12)
$labletype = GUICtrlCreateLabel("",10,240,450,25)
GUICtrlSetFont($labletype,12)
$lablehard = GUICtrlCreateLabel("",10,270,450,25)
GUICtrlSetFont($lablehard,12)
$lable = GUICtrlCreateLabel("硬件ID:",10,320,450,25)
GUICtrlSetFont($lable,12)
$edit = GUICtrlCreateEdit("",10,350,450,100,$ES_READONLY)
GUICtrlSetFont($edit,12)
$button = GUICtrlCreateButton("复制",500,350,80,40)
GUICtrlSetFont($button,12)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "MyMsgCallBack")
ReadData()
PutData()
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $button
ClipPut(GUICtrlRead($edit))
MsgBox(64,"提示","硬件ID,已复制到剪切板!")
EndSwitch
WEnd
Func ReadData()
Local $cnt
Local $i
Local $j
$cnt = 1
For $i = 1 to 99
$IDList[$i] = RegEnumKey($PciPath,$i)
If @error <> 0 then ExitLoop
$KeyList[$i] = RegEnumKey($PciPath&"\"&$IDList[$i],1)
$DeviceDesc[$i] = RegRead($PciPath&"\"&$IDList[$i]&"\"&$KeyList[$i],"DeviceDesc")
$HardwareID[$i] = RegRead($PciPath&"\"&$IDList[$i]&"\"&$KeyList[$i],"HardwareID")
$Class[$i] = RegRead($PciPath&"\"&$IDList[$i]&"\"&$KeyList[$i],"Class")
If @error = -1 Then
$Class[$cnt] = $Unkouw
ElseIf $Class[$i] = "System" Or $Class[$i] = "hdc" Or $Class[$i] = "USB" Then
ContinueLoop
Else
Select
Case $Class[$i] = "Display"
$Class[$cnt] = $VGA
Case $Class[$i] = "Net"
$Class[$cnt] = $NET
Case $Class[$i] = "MEDIA"
$Class[$cnt] = $SND
Case Else
$Class[$cnt] = $OTHER
EndSelect
EndIf
$DeviceDesc[$cnt] = $DeviceDesc[$i]
$HardwareID[$cnt] = $HardwareID[$i]
$cnt += 1
Next
For $j = 1 To 10
$IDList[$j+$i] = RegEnumKey($HDAudioPath,$j)
If @error <> 0 then ExitLoop
$KeyList[$j+$i] = RegEnumKey($HDAudioPath&"\"&$IDList[$j+$i],1)
$DeviceDesc[$j+$i] = RegRead($HDAudioPath&"\"&$IDList[$j+$i]&"\"&$KeyList[$j+$i],"DeviceDesc")
$HardwareID[$j+$i] = RegRead($HDAudioPath&"\"&$IDList[$j+$i]&"\"&$KeyList[$j+$i],"HardwareID")
$Vendor[$j+$i] = StringMid($IDList[$j+$i],13,4)
If $Vendor[$j+$i] = "10DE" Or $Vendor[$j+$i] = "1002" Then
ContinueLoop
Else
$Class[$cnt] = $SND
$DeviceDesc[$cnt] = $DeviceDesc[$j+$i]
$HardwareID[$cnt] = $HardwareID[$j+$i]
$cnt += 1
EndIf
Next
$Class[0] = $cnt - 1
EndFunc
Func PutData()
Local $tmp
Local $i
For $i = 1 To $Class[0]
$HardwareID[$i] = StringAddCR($HardwareID[$i])
$item[$i] = GUICtrlCreateListViewItem($Class[$i]&'|'&$DeviceDesc[$i]&'|'&$HardwareID[$i],$listview)
GUICtrlSetFont($item[$i],12)
Next
_GUICtrlListView_SetItemSelected($listview,0)
GUICtrlSetData($labletype,$Class[1])
GUICtrlSetData($lablehard,$DeviceDesc[1])
$tmp = $HardwareID[1]
$tmp = StringAddCR($tmp)
GUICtrlSetData($edit,$tmp)
EndFunc
Func MyMsgCallBack($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
Local $index
Local $read[3]
Local $i
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;选择产生事件的控件
Case $listview
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
$index = _GUICtrlListView_GetSelectedIndices($listview)
If Not StringLen($index) Then Return; 这里用以判断是否选定了ListViewItem
;
$index = Number($index)
For $i = 0 To 2
$read[$i] = _GUICtrlListView_GetItemText($listview, $index,$i)
Next
GUICtrlSetData($labletype,$read[0])
GUICtrlSetData($lablehard,$read[1])
GUICtrlSetData($edit,$read[2])
;
Case $NM_DBLCLK ; 双击
Case $NM_RCLICK ; 右击
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
|