Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#4

AW: Betriebsstunden einer Festplatte auslesen?

  Alt 6. Nov 2010, 19:01
Der Thread ist zwar alt, aber weil so etwas immer wieder gesucht wird:

ATTR_POWER_ON_HRS_COUNT u.a.

http://www.magsys.co.uk/delphi/magwmi.asp
http://www.magsys.co.uk/download/software/magwmi53.zip

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls,
  smart_drv, magsubs1, magwmi;// http://www.magsys.co.uk/download/software/magwmi53.zip

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Memo1: TMemo;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    function GetDriveTemp(drive:longint):byte;

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function HexToStr(w : Int64) : string;
const
  ByteToChar : array[0..$F] of char ='0123456789ABCDEF';
var
  s : string;
  i : integer;
  x : int64;
begin
  s := '';
  x := w;
  for i := 0 to 3 do
  begin
    s := ByteToChar[Byte(x) shr 4] + ByteToChar[Byte(x) and $F] + s;
    x := x shr 8;
  end;
  HexToStr := s;
end;


function TForm1.GetDriveTemp(drive:Integer):byte;
var i, B2 : Integer;
begin
result:=0; Memo1.clear;
ReadSMART;
for i:=0 to 255 do
begin
// ATTR_READ_ERROR_RATE = 1;
if SCOP[0].attr[i].bAttrID=1 then
begin
result:=SCOP[0].attr[i].Raw[0];
Memo1.lines.add('ATTR_READ_ERROR_RATE: '+HexToStr(result));
end;
//ATTR_POWER_ON_HRS_COUNT = 9;
if SCOP[0].attr[i].bAttrID=9 then
begin
B2:= SCOP[0].attr[i].Raw[0]+(SCOP[0].attr[i].Raw[1]*256);
Memo1.lines.add('ATTR_POWER_ON_HRS_COUNT in hours: '+IntToStr(B2));
end;
//ATTR_TEMPERATURE_CELCIUS = 194 ;
if SCOP[0].attr[i].bAttrID=194 then
begin
result:=SCOP[0].attr[i].Raw[0];
Memo1.lines.add('ATTR_TEMPERATURE_CELCIUS: '+IntToStr(result));
break;
end;
end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
Begin
GetDriveTemp(0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
GetDriveTemp(0);
end;

end.

(*
Const
  ATTR_INVALID = 0;
  ATTR_READ_ERROR_RATE = 1;
  ATTR_THROUGHPUT_PERF = 2;
  ATTR_SPIN_UP_TIME = 3;
  ATTR_START_STOP_COUNT = 4;
  ATTR_REALLOC_SECTOR_COUNT = 5;
  ATTR_READ_CHANNEL_MARGIN = 6;
  ATTR_SEEK_ERROR_RATE = 7;
  ATTR_SEEK_TIME_PERF = 8;
  ATTR_POWER_ON_HRS_COUNT = 9;
  ATTR_SPIN_RETRY_COUNT = 10;
  ATTR_CALIBRATION_RETRY_COUNT = 11;
  ATTR_POWER_CYCLE_COUNT = 12;
  ATTR_EMERGENCY_RETRACT_CYCLE = 192 ; // C0
  ATTR_LOAD_CYCLE_COUNT = 193 ; // C1
  ATTR_TEMPERATURE_CELCIUS = 194 ; // C2
  ATTR_HARDWARE_ECC = 195 ; // C3
  ATTR_REALLOCATION_EVENT_COUNT = 196 ; // C4
  ATTR_CURRENT_PENDING_SECTOR = 197 ; // C5
  ATTR_OFF_LINE_UNCORRECTABLE = 198 ; // C6
  ATTR_ULTRA_ATA_CRC_ERROR_RATE = 199 ; // C7
  ATTR_MULTI_ZONE_ERROR_RATE = 200 ; // C8
  ATTR_SOFT_READ_ERROR_RATE = 201 ; // C9
  ATTR_OFF_TRACK_ERRORS = 201 ; // C9 - alternative Maxtor
  ATTR_TA_INCREASE_COUNT = 202 ; // CA
  ATTR_RUN_OUT_CANCEL = 203 ; // CB
  ATTR_ECC_ERRORS = 203 ; // CB - alternative Maxtor
  ATTR_SHOCK_COUNT_WRITE_OPS = 204 ; // CC
  ATTR_SHOCK_RATE_WRITE_OPS = 205 ; // CD
  ATTR_SPIN_HIGH_CURRENT = 207 ; // CE
  ATTR_SPIN_BUZZ = 208 ; // CF
  ATTR_OFFLINE_SEEK_PERF = 209 ; // D0
  *)
  Mit Zitat antworten Zitat