#include <SetupApi.au3>
#include <array.au3>
Local $aryInfo[1]
Local $aryDisplay[1][2]
Local $aryNetwork[1][2]
Local $aryChipset[1][2]
Local $aryAudio[1][2]
$aryDisplay[0][0] = 0
$aryNetwork[0][0] = 0
$aryChipset[0][0] = 0
$aryAudio[0][0] = 0
FindDeviceRecur(_CM_Locate_DevNode(""))
; This is what you want.
_ArrayDisplay($aryDisplay)
Func FindDeviceRecur($hDevInst)
$aChild = _CM_Enumerate_Children($hDevInst)
For $i = 1 To $aChild[0]
$hDevInst = _CM_Locate_DevNode($aChild[$i])
$Class = _CM_Get_DevNode_Registry_Property($hDevInst, $CM_DRP_CLASS)
$sDescr = _CM_Get_DevNode_Registry_Property($hDevInst, 1)
$Version = Get_Driver_Version($hDevInst)
_2ArrayAdd($aryInfo, $Class & "|" & $sDescr)
If $Class = "Display" Then
;MsgBox(0,"","显卡型号:" & $sDescr & @CRLF & @CRLF & "驱动版本:" & $Version)
_2ArrayAdd($aryDisplay,$sDescr & "|" & $Version)
EndIf
If $Class = "Net" Then
;MsgBox(0,""," 网卡型号:" & $sDescr & @CRLF & @CRLF & "驱动版本:" & $Version)
_2ArrayAdd($aryNetwork,$sDescr & "|" & $Version)
EndIf
If $Class = "Processor" Then
;MsgBox(0,"","处理器:" & $sDescr & @CRLF & @CRLF & "驱动版本:" & $Version)
_2ArrayAdd($aryChipset,$sDescr & "|" & $Version)
EndIf
If $Class = "Media" Then
;MsgBox(0,"","声卡" & $sDescr & @CRLF & @CRLF & "驱动版本:" & $Version)
_2ArrayAdd($aryAudio,$sDescr & "|" & $Version)
EndIf
;此处只是为了取显卡的信息,所以加了判断,去掉可以取所有硬件驱动版本信息
FindDeviceRecur($hDevInst)
Next
EndFunc
Func _2ArrayAdd(ByRef $ary, $Data)
Local $iLength = UBound($ary) + 1
Local $DataList = StringSplit($Data, "|")
If IsArray($DataList) Then
ReDim $ary[$iLength][2]
$ary[$iLength - 1][0] = $DataList[1]
$ary[$iLength - 1][1] = $DataList[2]
EndIf
Return $ary
EndFunc
Func Get_Driver_Version($hDevInst)
$ClassGUID = _CM_Get_DevNode_Registry_Property($hDevInst, 10)
If $ClassGUID = "" Then Return "Unknown"
If @OSArch = "X86" Then
$Reg = "HKLM\SYSTEM\ControlSet001\Control\Class\"
Else
$Reg = "HKLM64\SYSTEM\ControlSet001\Control\Class\"
EndIf
$Version = RegRead($Reg & $ClassGUID, "DriverVersion")
If $Version = "" Then
Return "Unknown"
Else
Return $Version
EndIf
EndFunc
|