|
Func _GetUSBDrives()
Local $aDletters[1]
$strComputer = "."
Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
Local $colDiskDrives = $objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive")
For $objDrive In $colDiskDrives
If $objDrive.pnpdeviceid <> RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum", _
RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum","count")-1) then Continueloop
$strDeviceID = StringReplace($objDrive.DeviceID, "\", "\\")
Local $colPartitions = $objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskDrive.DeviceID=""" & _
$strDeviceID & """} WHERE AssocClass = " & _
"Win32_DiskDriveToDiskPartition")
For $objPartition In $colPartitions
Local $colLogicalDisks = $objWMIService.ExecQuery _
("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _
$objPartition.DeviceID & """} WHERE AssocClass = " & _
"Win32_LogicalDiskToPartition")
For $objLogicalDisk In $colLogicalDisks
_ArrayAdd($aDletters,$objLogicalDisk.DeviceID )
Next
Next
Next
Return $aDletters
EndFunc
偶已关闭wmi.................................
还有.程序中存在一些小错误... |
|