rikthhpgf2005 发表于 2010-4-7 08:56:18

求解硬盘使用时间

本帖最后由 rikthhpgf2005 于 2010-4-7 13:04 编辑

如何读取硬盘使用时间????

水木子 发表于 2010-4-7 09:01:59

《论坛发帖规则》

rikthhpgf2005 发表于 2010-4-7 09:14:54

回复 2# 水木子


    没发错!指教?

netegg 发表于 2010-4-7 14:08:37

错没错,好好看看

dtooboss 发表于 2010-4-7 14:57:27

本帖最后由 dtooboss 于 2010-4-7 14:59 编辑

au3没这么强大,准确的说,au3连硬盘分区表之类的都不能够直接操作,更别提这些存储在硬盘的逻辑电路中的信息了,
这个需要专用工具读取,需要读取硬盘的ram bios中的信息,类似于主板的bios cmos 读取。

折中的办法是,找个提供了这个bios接口的动态链接库文件,用dllcall or api 来操作。

awfymwvf 发表于 2010-4-7 15:07:57

AU3现在好像不能实现这个功能

dtooboss 发表于 2010-4-7 15:43:52

想到了一个办法,正在写代码中.........................

rikthhpgf2005 发表于 2010-4-7 16:16:30

回复 7# dtooboss


   =====:face (37):

dtooboss 发表于 2010-4-7 16:52:12

回复 8# rikthhpgf2005

数据自己分离

rikthhpgf2005 发表于 2010-4-7 17:05:57

回复 9# dtooboss


    谢谢!!!!!!!!!!

newuser 发表于 2010-4-7 17:13:39

回复 5# dtooboss

很惊讶,学习中。。

dtooboss 发表于 2010-4-7 17:36:45

本帖最后由 dtooboss 于 2010-4-7 17:38 编辑

回复dtooboss


    谢谢!!!!!!!!!!
rikthhpgf2005 发表于 2010-4-7 17:05 http://www.autoitx.com/images/common/back.gif

取得不同的硬盘的状态需要指定盘符,也可通过下拉菜单传递参数

还可以释放exe到内存中运行。具体看你需求了。

rikthhpgf2005 发表于 2010-4-8 09:12:39

WMI实现:face (37):
#include <array.au3>

Const $wbemFlagReturnImmediately = 0x10
Const $wbemFlagForwardOnly = 0x20

Dim $strComputer = "."; Retrieve remote data fill in the "Remote Computer IP or Name"

Dim $objWMIService, $oMyError, $oDict
Dim $colItems, $strReserved, $strVendorSpecific, $strVendorSpecific4, $Output

; Initialize error handler and Objects
        $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\WMI")
        $oDict = ObjCreate("Scripting.Dictionary")

        $colItems1 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_ATAPISmartData", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
       
        $colItems2 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictThresholds", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
                                                                                  
        $colItems3 = $objWMIService.ExecQuery("SELECT * FROM MSStorageDriver_FailurePredictStatus", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
        _CreateDict() ; Create Dictionary
       
        ConsoleWrite ($strComputer&@CR)                                                          
       
        For $objItem In $colItems3
      $strVendorSpecific3 = $objItem.PredictFailure
          $strVendorSpecific3 = $objItem.Reason
          ConsoleWrite ("PredictFailure: " & $strVendorSpecific3&@CR)
          ConsoleWrite ("PredictReason: " & $strVendorSpecific3&@CR)
    Next
       
        For $objItem In $colItems2
      $strVendorSpecific2 = $objItem.VendorSpecific
          ConsoleWrite ("FailurePredictThresholds: " & _ArrayToString($strVendorSpecific2,",")&@CR)
    Next

   For $objItem In $colItems1
      ConsoleWrite ("Active: " & $objItem.Active&@CR)
      ConsoleWrite ("Checksum: " & $objItem.Checksum&@CR)
      ConsoleWrite ("ErrorLogCapability: " & $objItem.ErrorLogCapability&@CR)
      ConsoleWrite ("ExtendedPollTimeInMinutes: " & $objItem.ExtendedPollTimeInMinutes&@CR)
      ConsoleWrite ("InstanceName: " & $objItem.InstanceName&@CR)
      ConsoleWrite ("Length: " & $objItem.Length&@CR)
      ConsoleWrite ("OfflineCollectCapability: " & $objItem.OfflineCollectCapability&@CR)
      ConsoleWrite ("OfflineCollectionStatus: " & $objItem.OfflineCollectionStatus&@CR)
                $strReserved = $objItem.Reserved
      ConsoleWrite ("Reserved: " & _ArrayToString($strReserved,",")&@CR)
          ConsoleWrite ("SelfTestStatus: " & $objItem.SelfTestStatus&@CR)
      ConsoleWrite ("ShortPollTimeInMinutes: " & $objItem.ShortPollTimeInMinutes&@CR)
      ConsoleWrite ("SmartCapability: " & $objItem.SmartCapability&@CR)
      ConsoleWrite ("TotalTime: " & $objItem.TotalTime&@CR)
      $strVendorSpecific = $objItem.VendorSpecific
               
               
        ConsoleWrite ("VendorSpecific: " & _ArrayToString($strVendorSpecific,",")&@CR)
        ConsoleWrite ("VendorSpecific2: " & $objItem.VendorSpecific2&@CR)
        ConsoleWrite ("VendorSpecific3: " & $objItem.VendorSpecific3&@CR)
                $strVendorSpecific4 = $objItem.VendorSpecific4
        ConsoleWrite ("VendorSpecific4: " & _ArrayToString($strVendorSpecific4,",")&@CR)
Next

Dim $Temp = [$strVendorSpecific > $strVendorSpecific2,$strVendorSpecific > $strVendorSpecific2]
Dim $Status
Select
        Case $Temp > 0
                $Status = "OK"
        Case $Temp > 0
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case $strVendorSpecific > $strVendorSpecific2
                $Status = "OK"
        Case Else
                $Status = "Not OK"
EndSelect

Dim $Output1= "ID"&@tab&"Attribute"&@tab&@tab&@tab&@tab&"Flag"&@tab&"Threshold"&@tab&"Value"&@tab&"Worst"&@tab&"Raw"&@tab&"Status"&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@tab&@tab&$Status&@CR

Dim $Output2=$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&@tab&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific&@CR _
                &$strVendorSpecific&@tab&$oDict.Item($strVendorSpecific)&@tab&$strVendorSpecific&@tab&$strVendorSpecific2&@tab&$strVendorSpecific&@tab&$strVendorSpecific _       

MsgBox(0,"Output : "&$strComputer, $Output1&$Output2)


Func _CreateDict()
        $oDict.Add(1,"Read Error Rate")
        $oDict.Add(2,"Throughput Performance")
        $oDict.Add(3,"Spin-Up Time")
        $oDict.Add(4,"Start/Stop Count")
        $oDict.Add(5,"Reallocated Sectors Count")
        $oDict.Add(6,"Read Channel Margin")
        $oDict.Add(7,"Seek Error Rate Rate")
        $oDict.Add(8,"Seek Time Performance")
        $oDict.Add(9,"Power-On Hours (POH)")
        $oDict.Add(10,"Spin Retry Count")
        $oDict.Add(12,"Device Power Cycle Count")
        $oDict.Add(191,"G-Sense Error Rate Frequency")
        $oDict.Add(192,"Power-Off Park Count")
        $oDict.Add(193,"Load/Unload Cycle")
        $oDict.Add(194,"HDA Temperature")
        $oDict.Add(195,"ECC Corrected Count")
        $oDict.Add(196,"Reallocated Event Count")
        $oDict.Add(197,"Current Pending Sector Count")
        $oDict.Add(198,"Uncorrectable Sector Count")
        $oDict.Add(199,"UltraDMA CRC Error Count")
        $oDict.Add(200,"Write Error Rate")
        $oDict.Add(201,"Soft Read Error Rate")
        $oDict.Add(202,"Address Mark Errors Frequency")
        $oDict.Add(203,"ECC errors (Maxtor: ECC Errors)")
EndFunc

;This is COM error handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8)
Msgbox(0,"COM Error Test","We intercepted a COM Error !"       & @CRLF& @CRLF & _
                       "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
                       "err.windescription:"   & @TAB & $oMyError.windescription & @CRLF & _
                       "err.number is: "         & @TAB & $HexNumber            & @CRLF & _
                       "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
                       "err.scriptline is: "   & @TAB & $oMyError.scriptline   & @CRLF & _
                       "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
                       "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
                       "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
                        )
SetError(1); to check for after this function returns
Endfunc

yangfengoo 发表于 2010-4-8 09:38:11

楼上好强大:face (12):

gaoxingang_ 发表于 2010-4-13 11:46:15

回复 13# rikthhpgf2005


    牛X
页: [1] 2
查看完整版本: 求解硬盘使用时间