AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

S.M.A.R.T. figured out

Ein Thema von Razor · begonnen am 6. Aug 2007 · letzter Beitrag vom 23. Dez 2013
Antwort Antwort
Razor
(Gast)

n/a Beiträge
 
#1

S.M.A.R.T. figured out

  Alt 6. Aug 2007, 11:42
Okay source is bellow and example also it shows disk temperature for scsi,ide,pata,sata or whatever you want to call it.Just i didnt know how to do real s.m.a.r.t. in a listbox?




Delphi-Quellcode:
unit smart;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,smart_drv, StdCtrls, Spin;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    SpinEdit1: TSpinEdit;
    function GetDriveTemp(drive:longint):byte;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function tform1.GetDriveTemp(drive:longint):byte;
var i:longint;
begin
result:=0;
for i:=0 to 255 do
begin
if SCOP[ 0 ].attr[ i ].bAttrID=194 then
begin
result:=SCOP[ 0].attr[ i ].Raw[0];
break;
end;
end;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
            
            spinedit1.Value:=getdrivetemp(0);
end;


procedure TForm1.FormCreate(Sender: TObject);

 var
 i:integer;
 b:longint;
begin
 ReadSMART;
for i:=0 to 3 do
begin
if hSMARTIOCTL[i] = INVALID_HANDLE_VALUE then continue;
b:=GetDriveTemp(i);
{if hdd_temps[i]=b then continue;
hdd_temps[i]:=b;
end;
}
     end;
    end;
end.
Delphi-Quellcode:
unit smart_drv;

interface


uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;



procedure OpenSMART;
procedure ReadSMART;
procedure CloseSMART;
function GetATTRName(attr:byte;var comm:string):string;
function GetFlags(flags:word):string;
procedure SwapBytes( var buf; count : integer );

Type
    TIDSECTOR = packed record
   wGenConfig:word;
   wNumCyls:word;
{   wReserved:word;}
   wNumHeads:word;
   wBytesPerTrack:word;
   wBytesPerSector:word;
   wSectorsPerTrack:word;
   wVendorUnique : array[0..2] of word;
   sSerialNumber:array[0..19] of char;
   wBufferType:word;
   wBufferSize:word;
   wECCSize:word;
   sFirmwareRev:array[0..7] of char;
   sModelNumber:array[0..39] of char;
   wMoreVendorUnique:word;
   wDoubleWordIO:word;
   wCapabilities:word;
   wReserved1:word;
   wPIOTiming:word;
   wDMATiming:word;
   wBS:word;
   wNumCurrentCyls:word;
   wNumCurrentHeads:word;
   wNumCurrentSectorsPerTrack:word;
   ulCurrentSectorCapacity:dword;
   wMultSectorStuff:word;
   ulTotalAddressableSectors:dword;
   wSingleWordDMA:word;
   wMultiWordDMA:word;
        hz : array[1..72] of byte;
        LBA48 : array[0..5] of byte;
   bReserved:array[0..127] of byte;
        end;

    TGETVERSIONOUTPARAMS = packed record
      version : byte;
      revision : byte;
      reserved : byte;
      IDEDevMap : byte;
      Capabilities : dword;
      reserved1 : dword;
      reserved2 : dword;
      reserved3 : dword;
      reserved4 : dword;
    End;


    TIDEREGS = packed record
        bFeaturesReg:byte;      // Used for specifying SMART "commands".
        bSectorCountReg:byte;    // IDE sector count register
        bSectorNumberReg:byte;    // IDE sector number register
       bCylLowReg:byte;         // IDE low order cylinder value
       bCylHighReg:byte;      // IDE high order cylinder value
       bDriveHeadReg:byte;      // IDE drive/head register
       bCommandReg:byte;      // Actual IDE command.
       bReserved:byte;
    end;          // reserved for future use. Must be zero.


 TSENDCMDINPARAMS = packed record
     cBufferSize:dword;      // Buffer size in bytes
      irDriveRegs:TIDERegs;      // Structure with drive register values.
      bDriveNumber:byte;      // Physical drive number to send
                     // command to (0,1,2,3).
      bReserved: array[0..3] of byte;      // Reserved for future expansion.
      dwReserved: array [0..4] of dword;      // For future use.
      bBuffer:array[0..1024*8] of byte;         // Input buffer.
    end;


 TDRIVERSTATUS = packed record
   bDriverError:byte;      // Error code from driver,
               // or 0 if no error.
   bIDEStatus:byte;       // Contents of IDE Error register.
               // Only valid when bDriverError
               // is SMART_IDE_ERROR.
   bReserved:array[0..3] of byte;   // Reserved for future expansion.
   dwReserved:array[0..1] of dword;// Reserved for future expansion.
  end;

   TDRIVEATTRIBUTE = packed record
          bAttrID:byte;      // Identifies which attribute
          wStatusFlags:word;   // see bit definitions below
         Value:byte;      // Current normalized value
         Worst:byte;   // How bad has it ever been?
         Raw:array[0..5] of byte;   // Un-normalized value
          bReserved:byte;      // ...
    end;

   TATTRTHRESHOLD = packed record
        bAttrID : byte;
        bWarrantyThreshold : byte;
        reserved : array[0..9] of byte;
    end;

 TSENDCMDOUTPARAMS = packed record
   cBufferSize : DWord;      // Size of bBuffer in bytes
   DriverStatus : TDriverStatus;      // Driver status structure.
   attr : array[0..255] of TDRIVEATTRIBUTE;         // Buffer of arbitrary length in which to store the data read from the                                  // drive.
    end;

   TSMARTATTRNAME = record
    value : word;
    name : string[40];
    comm : string[160];
   end;

   THDDInfo = record
    Model : string;
    FW : string;
    SN : string;
    LBABits : integer;
    LBASize : int64;
    Cache : integer;
   End;

var
  VersParams : TGETVERSIONOUTPARAMS;
  SCOP : array[0..3] of TSENDCMDOUTPARAMS;
  AttrCnt : array[0..3] of word;
  hSMARTIOCTL : array[0..3] of thandle;
  IDSECTOR : array[0..3] of TIDSECTOR;
  Thresholds : array[0..3,0..255] of TATTRTHRESHOLD;
  HDDInfo : array[0..3] of THDDInfo;

const
  PRE_FAILURE_WARRANTY = $01;
  ON_LINE_COLLECTION = $02;
  PERFORMANCE_ATTRIBUTE = $04;
  ERROR_RATE_ATTRIBUTE = $08;
  EVENT_COUNT_ATTRIBUTE = $10;
  SELF_PRESERVING_ATTRIBUTE = $20;
  IDENTIFY_BUFFER_SIZE    = 512;
  READ_THRESHOLD_BUFFER_SIZE = 512;

  SMART_READ_ATTRIBUTE_THRESHOLDS = $D1;

  IDE_ATAPI_ID       = $A1;   // Returns ID sector for ATAPI.
  IDE_ID_FUNCTION    = $EC;   // Returns ID sector for ATA.


var
   SCIP : TSENDCMDINPARAMS;

const
   DFP_GET_VERSION = $00074080;
   DFP_RECEIVE_DRIVE_DATA = $0007c088;
   DFP_SEND_DRIVE_COMMAND = $0007c084;
   SMART_ENABLE_SMART_OPERATIONS = $D8;
   SMART_DISABLE_SMART_OPERATIONS = $D9;
   SMART_RETURN_SMART_STATUS    = $DA;
   SMART_CYL_LOW = $4F;
   SMART_CYL_HI = $C2;
   IDE_EXECUTE_SMART_FUNCTION    = $B0;
   READ_ATTRIBUTE_BUFFER_SIZE    = 512;
   SMART_READ_ATTRIBUTE_VALUES    = $D0;   // ATA4: Renamed

   AttrCount = 45;
   SmartAttrNames : array[1..AttrCount] of TSMARTAttrName=
   (
   (Value:1;Name:'Raw Read Error Rate';Comm:'Frequency of errors appearance while reading RAW data from a disk'),
   (Value:2;Name:'Throughput Performance';Comm:'The average efficiency of hard disk'),
   (Value:3;Name:'Spin Up Time';Comm:'Time needed by spindle to spin-up'),
   (Value:4;Name:'Start/Stop Count';Comm:'Number of start/stop cycles of spindle'),
   (Value:5;Name:'Reallocated Sector Count';Comm:'Quantity of remapped sectors'),
   (Value:6;Name:'Read Channel Margin';Comm:'Reserve of channel while reading'),
   (Value:7;Name:'Seek Error Rate';Comm:'Frequency of errors appearance while positioning'),
   (Value:8;Name:'Seek Time Performance';Comm:'The average efficiency of operations while positioning'),
   (Value:9;Name:'Power-On Hours Count';Comm:'Quantity of elapsed hours in the switched-on state'),
   (Value:10;Name:'Spin-up Retry Count';Comm:'Number of attempts to start a spindle of a disk'),
   (Value:11;Name:'Calibration Retry Count';Comm:'Number of attempts to calibrate a drive'),
   (Value:12;Name:'Power Cycle Count';Comm:'Number of complete start/stop cycles of hard disk'),
   (Value:13;Name:'Soft Read Error Rate';Comm:'Frequency of "program" errors appearance while reading data from a disk'),
   (Value:191;Name:'G-Sense Error Rate';Comm:'Frequency of mistakes appearance as a result of impact loads'),
   (Value:192;Name:'Power-Off Retract Cycle';Comm:'Number of the fixed "turning off" drive cycles (Fujitsu: Emergency Retract Cycle Count)'),
   (Value:193;Name:'Load/Unload Cycle Count';Comm:'Number of cycles into Landing Zone position'),
   (Value:194;Name:'HDD Temperature';Comm:'Temperature of a Hard Disk Assembly'),
   (Value:195;Name:'Hardware ECC Recovered';Comm:'Frequency of the on the fly errors (Fujitsu: ECC On The Fly Count)'),
   (Value:196;Name:'Reallocated Event Count';Comm:'Quantity of remapping operations'),
   (Value:197;Name:'Current Pending Sector Count';Comm:'Current quantity of unstable sectors (waiting for remapping)'),
   (Value:198;Name:'Off-line Scan Uncorrectable Count';Comm:'Quantity of uncorrected errors'),
   (Value:199;Name:'UltraDMA CRC Error Rate';Comm:'Total quantity of errors CRC during UltraDMA mode'),
   (Value:200;Name:'Write Error Rate';Comm:'Frequency of errors appearance while recording data into disk (Western Digital: Multi Zone Error Rate)'),
   (Value:201;Name:'Soft Read Error Rate';Comm:'Frequency of the off track errors (Maxtor: Off Track Errors)'),
   (Value:202;Name:'Data Address Mark Errors';Comm:'Frequency of the Data Address Mark errors'),
   (Value:203;Name:'Run Out Cancel';Comm:'Frequency of the ECC errors (Maxtor: ECC Errors)'),
   (Value:204;Name:'Soft ECC Correction';Comm:'Quantity of errors corrected by software ECC'),
   (Value:205;Name:'Thermal Asperity Rate';Comm:'Frequency of the thermal asperity errors'),
   (Value:206;Name:'Flying Height';Comm:'The height of the disk heads above the disk surface'),
   (Value:207;Name:'Spin High Current';Comm:'Quantity of used high current to spin up drive'),
   (Value:208;Name:'Spin Buzz';Comm:'Quantity of used buzz routines to spin up drive'),
   (Value:209;Name:'Offline Seek Performance';Comm:'Drives seek performance during offline operations'),
   (Value:220;Name:'Disk Shift';Comm:'Shift of disk is possible as a result of strong shock loading in the store, as a result of it`s falling or for other reasons'),
   (Value:221;Name:'G-Sense Error Rate';Comm:'This attribute is an indication of shock-sensitive sensor - total quantity of errors appearance as a result of impact loads '),
   (Value:222;Name:'Loaded Hours';Comm:'Loading on drive caused by the general operating time of hours it stores'),
   (Value:223;Name:'Load/Unload Retry Count';Comm:'Loading on drive caused by numerous recurrences of operations like: reading, recording, positioning of heads, etc.'),
   (Value:224;Name:'Load Friction';Comm:'Loading on drive caused by friction in mechanical parts of the store'),
   (Value:225;Name:'Load/Unload Cycle Count';Comm:'Total of cycles of loading on drive'),
   (Value:226;Name:'Load-in Time';Comm:'General time of loading for drive'),
   (Value:227;Name:'Torque Amplification Count';Comm:'Quantity efforts of the rotating moment of a drive'),
   (Value:228;Name:'Power-Off Retract Count';Comm:'Quantity of the fixed turning off`s a drive'),
   (Value:230;Name:'GMR Head Amplitude';Comm:'Amplitude of heads trembling (GMR-head) in running mode'),
   (Value:231;Name:'Temperature';Comm:'Temperature of a drive'),
   (Value:240;Name:'Head Flying Hours';Comm:'Time while head is positioning'),
   (Value:250;Name:'Read Error Retry Rate';Comm:'Frequency of errors appearance while reading data from a disk')
   );

   flagnames : array[0..5] of string[2] = ('PF','OC','PA','ER','EC','SP');
implementation

{------------------------------------------------------------------}
function GetFlags(flags:word):string;
var
  i : integer;
  s : string;

Begin
 s := '';
  for i := 0 to 5 do
    if flags and (1 shl i) <> 0 then
      s := s + flagnames[i]+#32;
 GetFlags := s;
End;

{------------------------------------------------------------------}
function GetATTRName(attr:byte;var comm:string):string;
var
  i : integer;
begin
  for i := 1 to attrCount do
   begin
    if attr = SmartAttrNames[i].Value then
     begin
      GetAttrName := SmartAttrNames[i].name;
      Comm := SmartAttrNames[i].comm;
      exit;
     end;
   end;
 GetAttrName := 'Unknown';
end;

{------------------------------------------------------------------}
procedure SwapBytes( var buf; count : integer );
Assembler;
Asm
        pushad
        mov esi, buf
        mov edi, esi
        mov ecx, count
        shr ecx, 1
        test ecx, ecx
        jz @@exit
        @@rep:
        lodsw
        xchg ah, al
        stosw
        dec ecx
        jnz @@rep
@@exit:
        popad
End;

{------------------------------------------------------------------}
procedure OpenSMART;
var
  i : integer;
  c : dword;
  s, s1, s2 : string;
  os : TOSVERSIONINFO;
  osver : (wvNT3,wvNT4,wvW2k,wvXP,wv95,wv98,wvME);
begin
 for i := 0 to 3 do
  begin

 os.dwPlatformId := 0;
 os.dwOSVersionInfoSize := sizeof(OSVERSIONINFO);
 GetVersionEx( os );

    osver := wv98;
    case OS.DwMajorVersion of
      3: osver := wvNT3;
      4: case OS.DwMinorVersion of
            0: if OS.dwPlatformId = VER_PLATFORM_WIN32_NT
               then osver := wvNT4
               else osver := wv95;
            10: osver := wv98;
            90: osver := wvME;
          end;
      5: case OS.DwMinorVersion of
            0: osver := wvW2K;
            1: osver := wvXP;
          end;
    end;

    hSMARTIOCTL[i] := 0;

    if (osver = wv98) or (osver = wv95) or (osver=wvME) then
    hSMARTIOCTL[i] := CreateFile('\\.\SMARTVSD', 0,0,NIL,
                        CREATE_NEW, 0, 0)
    else

     hSMARTIOCTL[i] := CreateFile(pchar( '\\.\PhysicalDrive'+format('%d',[i])),
                    GENERIC_READ or GENERIC_WRITE,
                    FILE_SHARE_READ or FILE_SHARE_WRITE,
                    NIL,
                    OPEN_EXISTING,
                    0,
                    0);

     if hSMARTIOCTL[i] = INVALID_HANDLE_VALUE then continue;

     DeviceIoControl(hSMARTIOCTL[i], DFP_GET_VERSION,
           NIL,
           0,
           @VersParams,
           sizeof(VersParams),
           c, NIL) ;

        FillChar( SCIP, SizeOf( SCIP ), 0 );
   SCIP.cBufferSize := 0;

   SCIP.irDriveRegs.bFeaturesReg := SMART_ENABLE_SMART_OPERATIONS;
   SCIP.irDriveRegs.bSectorCountReg := 1;
   SCIP.irDriveRegs.bSectorNumberReg := 1;
   SCIP.irDriveRegs.bCylLowReg := SMART_CYL_LOW;
   SCIP.irDriveRegs.bCylHighReg := SMART_CYL_HI;

   //
   // Compute the drive number.
   //
   SCIP.irDriveRegs.bDriveHeadReg := $A0 or (( i and 1) shl 4);
   SCIP.irDriveRegs.bCommandReg := IDE_EXECUTE_SMART_FUNCTION;
   SCIP.bDriveNumber := i;

        DeviceIoControl(hSMARTIOCTL[i], DFP_SEND_DRIVE_COMMAND,
                @SCIP, sizeof(TSENDCMDINPARAMS) - 1,
                @SCOP[i], sizeof(TSENDCMDOUTPARAMS) - 1,
                c, NIL);

   SCIP.cBufferSize := IDENTIFY_BUFFER_SIZE;
   SCIP.irDriveRegs.bFeaturesReg := 0;
   SCIP.irDriveRegs.bSectorCountReg := 1;
   SCIP.irDriveRegs.bSectorNumberReg := 1;
   SCIP.irDriveRegs.bCylLowReg := 0;
   SCIP.irDriveRegs.bCylHighReg := 0;

   SCIP.irDriveRegs.bDriveHeadReg := $A0 or ((i and 1) shl 4);
   SCIP.irDriveRegs.bCommandReg := IDE_ID_FUNCTION{ or IDE_ATAPI_ID};
   SCIP.bDriveNumber := i;
   SCIP.cBufferSize := IDENTIFY_BUFFER_SIZE;

        DeviceIoControl(hSMARTIOCTL[i], DFP_RECEIVE_DRIVE_DATA,
        @SCIP, sizeof(TSENDCMDINPARAMS) - 1,
        @SCOP[i], sizeof(TSENDCMDOUTPARAMS) + IDENTIFY_BUFFER_SIZE - 1,
        c, NIL) ;

        Move(SCOP[i].attr, IDSECTOR[i], SizeOf( IDSECTOR[i] ) );

        SCIP.cBufferSize := READ_THRESHOLD_BUFFER_SIZE;

        SCIP.irDriveRegs.bFeaturesReg := SMART_READ_ATTRIBUTE_THRESHOLDS;
        SCIP.irDriveRegs.bSectorCountReg := 1;
        SCIP.irDriveRegs.bSectorNumberReg := 1;
        SCIP.irDriveRegs.bCylLowReg := SMART_CYL_LOW;
        SCIP.irDriveRegs.bCylHighReg := SMART_CYL_HI;

        SCIP.irDriveRegs.bDriveHeadReg := $A0 or ((i and 1) shl 4);
        SCIP.irDriveRegs.bCommandReg := IDE_EXECUTE_SMART_FUNCTION;
        SCIP.bDriveNumber := i;

        DeviceIoControl(hSMARTIOCTL[i], DFP_RECEIVE_DRIVE_DATA,
        @SCIP, sizeof(TSENDCMDINPARAMS) - 1,
        @SCOP[i], sizeof(TSENDCMDOUTPARAMS) + READ_THRESHOLD_BUFFER_SIZE - 1,
        c, NIL) ;

        Move( SCOP[ i ].attr, Thresholds[ i ], SizeOf( Thresholds[ i ] ) );

        HDDInfo[ i ].LBASize := 0;
        HDDInfo[ i ].LBABits := 28;

   if idsector[i].ulTotalAddressableSectors = $FFFFFFF then
      begin
       move( idsector[i].lba48,HDDInfo[ i ].LBASize,6);
       HDDInfo[ i ].LBABits := 48;
      end
         else
       move( idsector[i].ulTotalAddressableSectors,HDDInfo[ i ].LBASize,4);

       s := IDSECTOR[i].sModelNumber +#32;
       SwapBytes( s[1], Length(s) );

       While (Length(s)<>0) and (s[Length(s)-1]=#32) do
         SetLength( s, length(s)-1);

   HDDInfo[ i ].Model := s;

   s := IDSECTOR[i].sFirmwareRev +#32;
   SwapBytes( s[1], Length(s) );

   HDDInfo[ i ].FW := s;

   s := IDSECTOR[i].sSerialNumber+#32;
   SwapBytes( s[1], Length(s) );
    While (Length(s)<>0) and (s[1]=#32) do
     delete(s,1,1);

   HDDInfo[ i ].SN := s;
   HDDInfo[ i ].Cache := IDSECTOR[i].wBufferSIze div 2;

  end;
end;

{------------------------------------------------------------------}
procedure CloseSMART;
var
  i : integer;
Begin
 for i := 0 to 3 do
     CloseHandle(hSMARTIOCTL[i]);

End;

{------------------------------------------------------------------}
procedure ReadSMART;
var
  i,j : integer;
  c : dword;
Begin

OpenSMART;
 for i := 0 to 3 do
  begin
     if hSMARTIOCTL[i] = INVALID_HANDLE_VALUE then continue;

   SCIP.cBufferSize := READ_ATTRIBUTE_BUFFER_SIZE;
   SCIP.irDriveRegs.bFeaturesReg := SMART_READ_ATTRIBUTE_VALUES;
   SCIP.irDriveRegs.bSectorCountReg := 1;
   SCIP.irDriveRegs.bSectorNumberReg := 1;
   SCIP.irDriveRegs.bCylLowReg := SMART_CYL_LOW;
   SCIP.irDriveRegs.bCylHighReg := SMART_CYL_HI;

   //
   // Compute the drive number.
   //
   SCIP.irDriveRegs.bDriveHeadReg := $A0 or (( i and 1) shl 4);
   SCIP.irDriveRegs.bCommandReg := IDE_EXECUTE_SMART_FUNCTION;
   SCIP.bDriveNumber := i;
        FillChar( SCOP[i], SizeOf( SCOP[i] ), 0 );

        DeviceIoControl(hSMARTIOCTL[i], DFP_RECEIVE_DRIVE_DATA,
                @SCIP, sizeof(TSENDCMDINPARAMS) - 1,
                @SCOP[ i ], sizeof(TSENDCMDOUTPARAMS) - 1 + READ_ATTRIBUTE_BUFFER_SIZE,
                c, NIL);

     AttrCnt[ i ] := 0;
     for j := 0 to 255 do
      if SCOP[ i ].attr[ j ].bAttrID = 0 then
       begin
         AttrCnt[ i ] := j;
         break;
       end;
  end;
 CloseSMART;

End;

{------------------------------------------------------------------}
end.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#2

Re: S.M.A.R.T. figured out

  Alt 20. Aug 2007, 18:35
Nobody knows how to solve this
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#3

Re: S.M.A.R.T. figured out

  Alt 23. Aug 2007, 18:40
*Push*

Edit: Does anybody know how to get smart values in a listview?
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#4

Re: S.M.A.R.T. figured out

  Alt 23. Aug 2007, 21:17
Where is your data structure where you save your data to? Collect the data in an adequate data structur. Displaying that data structure would be no problem.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#5

Re: S.M.A.R.T. figured out

  Alt 23. Aug 2007, 21:58
Maybe something like this can be used with the smartdrv.pas to get smart values.



Delphi-Quellcode:
//CAUTION BELLOW CODE DOES NOT PROVIDE SMART UNDER RAID,SATA OR PATA ONLY IDE! :P


procedure TMainFrm.doSmartClick(Sender: TObject);


var
    errinfo, model, serial: string ;
    diskbytes: int64 ;
    value1:integer;
    value2:integer ;
    value3:integer ;
    value4:integer ;
    value5:integer ;
     value6:integer ;
    value7:integer ;
    value8:integer ;
    value9:integer ;
    value10:integer ;
    value11:integer ;
    value12:integer;
    value13:integer ;

    SmartResult: TSmartResult ;
    I: integer ;

    function GetYN (value: boolean): string ;
    begin
        result := 'No' ;
        if value then result := 'Yes' ;
    end ;

begin

    value1 := (0) ;
    value2 := (1) ;
    value3 := (2) ;
    value4 := (3) ;
    value5 := (4) ;
    value6 := (5) ;
    value7 := (6) ;
    value8 := (7) ;
    value9 := (8) ;
    value10 := (9) ;
    value11 := (10) ;
    value12 := (11);
    value13 := (12) ;



     listview.ViewStyle:=vsreport;
    ListView.Items.Clear ;
    if NOT MagWmiSmartDiskInfo (DiskNum.Value, errinfo, model, serial, diskbytes) then
    begin
        if MagWmiScsiDiskInfo (DiskNum.Value, errinfo, model, serial, diskbytes) then
            ResInfo.Text := 'SCSI Serial: ' + serial {+
                                             ', Size = ' + Int64ToCStr (diskbytes) }

        else
            ResInfo.Text := errinfo ;
        exit ;
    end ;
    if naloziljeze=false then begin
         RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value1 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value2 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value3 )) ;
           RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value4 )) ;
            RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value5)) ;
             RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value6 )) ;
              RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value7 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value8 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value9 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value10 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value11 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value12 )) ;
          RzComboBox1.Items.Add(magwmi.MagWmiGetDiskModel( value13 )) ;
        if

         RzComboBox1.Items.Text='then RzComboBox1.Items.clear;
         button1.Click;
        end;

   //ResInfo.Text := 'IDE Model: ' + model + ', Serial: ' + serial +
                                            // ', Size = ' + Int64ToCStr (diskbytes) ;
    if NOT MagWmiSmartDiskFail (DiskNum.Value, SmartResult, errinfo) then
    begin
        ResInfo.Text := errinfo ;
        exit ;
    end ;
    if SmartResult.TotalAttrs = 0 then
    begin
        ResInfo.Text := ResInfo.Text + ' No SMART Attributes Returned - ' + errinfo ;
        exit ;
    end ;
    LabelInstances.Caption := 'SMART Attributes'  ;
    with ListView.Columns do
    begin

        Items [1].Caption := 'Name' ;
        Items [2].Caption := 'State' ;
        Items [3].Caption := 'Current' ;
        Items [4].Caption := 'Worst' ;
        Items [5].Caption := 'Threshold' ;
        Items [6].Caption := 'Raw Value' ;
        Items [7].Caption := 'Pre-Fail?' ;
        Items [8].Caption := 'Events?' ;
        Items [9].Caption := 'Error Rate?' ;
    end ;

// ListView.Items.Add.Caption := 'Hours ' + IntToStr (SmartResult.HoursRunning) ;
    //ListView.Items.Add.Caption := 'Realloc Sec ' + IntToStr (SmartResult.ReallocSector) ;
    if SmartResult.SmartFailTot <> 0 then
        ListView.Items.Add.Caption := 'SMART Test Failed, Bad Attributes ' +
                                             IntToStr (SmartResult.SmartFailTot)
    else
        //ListView.Items.Add.Caption := 'SMART Test Passed' ;
    for I := 0 to Pred (SmartResult.TotalAttrs) do
    begin
        with ListView.Items.Add do
        begin
            //Caption := IntToStr (SmartResult.AttrNum [I]) ;
             SubItems.Add (SmartResult.AttrName [I]) ;
            SubItems.Add (SmartResult.AttrState [I]) ;
            SubItems.Add (IntToStr (SmartResult.AttrCurValue [I])) ;
            SubItems.Add (IntToStr (SmartResult.AttrWorstVal [I])) ;
            SubItems.Add (IntToStr (SmartResult.AttrThreshold [I])) ;
            SubItems.Add (IntToCStr (SmartResult.AttrRawValue [I])) ;
            SubItems.Add (GetYN (SmartResult.AttrPreFail [I])) ;
            SubItems.Add (GetYN (SmartResult.AttrEvents [I])) ;
            SubItems.Add (GetYN (SmartResult.AttrErrorRate [I])) ;
        end ;
    end ;

    naloziljeze:=true;
end;
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#6

Re: S.M.A.R.T. figured out

  Alt 24. Aug 2007, 02:01
I am really sorry for little push i really am but >>>>


This program that ive made show on my brothers computer wich has 3 disks (samsung,baracuda,western digital)
Shows all temperatures the same.
http://img210.imageshack.us/img210/1...4001414ni6.jpg


Another dude i asked him,shows nothing at all.
Then i asked one last guy and it showed this under vista + he has 1 drive.So what you see is wrong.
http://img440.imageshack.us/img440/9969/hdtempsn3.png



And the funny thing is i get correct temperature for scsi drive wich is same as speedfan's but its bad becouse its not working for others,Can you test and post,so i can indetify the bug/problem....

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls,smart_drv;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    function GetDriveTemp(drive:longint):byte;
      procedure disktemp;
       function GetHDDCount: integer;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


 procedure tform1.disktemp;
 var
 i:integer;
 b:longint;
begin
 ReadSMART;
for i:=0 to 3 do
begin
if hSMARTIOCTL[i] = INVALID_HANDLE_VALUE then continue;
b:=GetDriveTemp(i);
end;
end;
 function tform1.GetHDDCount: integer;
var f, i: integer;
begin
  i := 0;
  repeat
    f := FileOpen('\\.\PHYSICALDRIVE' + IntToStr(i), fmOpenRead or fmShareDenyNone);
    if f = -1 then break;
    inc (i);
  until false;
  result := i;
end;
function tform1.GetDriveTemp(drive:longint):byte;
var i:longint;
begin
result:=0;
for i:=0 to 255 do
begin
if SCOP[ 0 ].attr[ i ].bAttrID=194 then
begin
result:=SCOP[ 0].attr[ i ].Raw[0];
break;
end;
end;
 end;







procedure TForm1.Timer1Timer(Sender: TObject);
var
SmartResult: TSmartResult ;
begin
if GetHDDCount=1 then begin
Label1.caption:='Disk 1 '+inttostr(GetDriveTemp(0))+' °C';
  end;
if GetHDDCount=3 then begin
Label1.caption:='Disk 1 '+inttostr(GetDriveTemp(0))+' °C';


Label2.caption:='Disk 2 '+inttostr(GetDriveTemp(1))+' °C';


Label3.caption:='Disk 3 '+inttostr(GetDriveTemp(2))+' °C';
             form1.caption:=inttostr(SmartResult.Temperature);
 end;

end;

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

end.
Angehängte Dateien
Dateityp: rar temperature_hdd_325.rar (8,8 KB, 92x aufgerufen)
  Mit Zitat antworten Zitat
WS1976
(Gast)

n/a Beiträge
 
#7

Re: S.M.A.R.T. figured out

  Alt 24. Aug 2007, 06:30
Hi Razor,
complete your sourcecode please!
What about magsubs1 and magwmi.

Rainer
  Mit Zitat antworten Zitat
WS1976
(Gast)

n/a Beiträge
 
#8

Re: S.M.A.R.T. figured out

  Alt 24. Aug 2007, 06:44
Hi all,
here the full sourcecode, changed source (Delphi designrules) with all Units!
Compiled with Delphi 7

Rainer
Angehängte Dateien
Dateityp: zip temp_hdd_697.zip (1,96 MB, 223x aufgerufen)
  Mit Zitat antworten Zitat
Razor
(Gast)

n/a Beiträge
 
#9

Re: S.M.A.R.T. figured out

  Alt 24. Aug 2007, 13:29
Thing is that you NEED the other stuff(i removed it already)so you uploaded that stuff for nothing.But i still havent figured it out why it shows same temps.
  Mit Zitat antworten Zitat
KyleKatarn

Registriert seit: 20. Dez 2013
10 Beiträge
 
#10

AW: S.M.A.R.T. figured out

  Alt 23. Dez 2013, 20:35
Does anyone knows how to do this for SCSI access (\\.\\scsi0 ,..) ?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:55 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz