本帖最后由 dreamneo 于 2013-7-30 17:53 编辑
通过WMI获取,下面的通过 AutoIt Scriptomatic 获得的代码简化,只留下了 名称 和 扇区数,想要什么自己再改吧!__wmi_Win32_DiskDrive()
Func __wmi_Win32_DiskDrive()
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
$Output &= "Caption: " & $objItem.Caption & @CRLF
$Output &= "TotalSectors: " & $objItem.TotalSectors & @CRLF
if Msgbox(1,"WMI Output",$Output) = 2 then ExitLoop
$Output=""
Next
Else
Msgbox(0,"WMI 输出","没有在类 " & "Win32_DiskDrive" & "中找到WMI对象" )
Endif
EndFunc
|