本帖最后由 yuantian 于 2021-1-31 15:05 编辑
表示可以
Local $iCnt, $iCheck, $vPNPID
$vDeviceID = "\\.\PHYSICALDRIVE0"
$vPNPID = _PNPIDFromPhysicalDriveID($vDeviceID)
MsgBox(0, "", $vPNPID)
Func _PNPIDFromPhysicalDriveID($vDriveID)
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $colItems = ""
Local $strComputer = "localhost"
Local $Output = ""
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objItem In $colItems
If $objItem.DeviceID == $vDriveID Then
Return $objItem.PNPDeviceID
EndIf
Next
EndIf
Return -1
EndFunc ;==>_PNPIDFromPhysicalDriveID
|