获取硬盘串号代码如下,不知道合不合要求
#include <array.au3>
Local $Hard
$Hard=_wmi_Win32_PhysicalMedia()
_ArrayDisplay($Hard)
Func _wmi_Win32_PhysicalMedia()
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $Output=""
Local $OutArr[1][2],$k=1
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_PhysicalMedia", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$diskdrive=$objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) then
For $objItem In $colItems
;$Output &= "Tag: " & $objItem.Tag & "|" & "SerialNumber: " & $objItem.SerialNumber & @CRLF
ReDim $OutArr[$k+1][2]
$OutArr[$k][0]=$objItem.Tag
$OutArr[$k][1]=$objItem.SerialNumber
$k+=1
Next
Endif
$k=1
If IsObj($diskdrive) Then
For $objItem In $diskdrive
;$Output&="Name:"&$objItem.Name&"|"&$objItem.caption &@CRLF
If $objItem.Name=$OutArr[$k][0] Then $OutArr[$k][0]=$objItem.caption
$k+=1
Next
EndIf
$OutArr[0][0]=UBound($OutArr)-1
Return $OutArr
EndFunc
|