|
![]() |
|
Registriert seit: 11. Okt 2003 Ort: Elbflorenz 44.542 Beiträge Delphi 12 Athens |
#1
Ihr geht doch jetzt auch mehrere \\.\PhysicalDriveX durch?
Hab jetzt mal bemerkt, daß meine IDE-Platte doch S.M.A.R.T kann (obwohl das BIOS immernoch sagt dort sei es "disabled" ![]() Die Demo aus ![]() ![]() Ist also (wie ich grad bemerkte) das selbe "Problem" wie in ![]()
Code:
//WinNT+
unit Mainform; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} Uses SmartIOCTL, SmartFunc; Procedure TForm1.Button1Click(Sender: TObject); Var lSmartHandle: THandle; lError: LongWord; lVersionInfo: TGetVersionOutParams; [color=red]i, i2: Integer;[/color] lBytesReturned: LongWord; lSuccess: Boolean; bIDCmd, bDfpDriveMap : Byte; lInCmd: TSendCmdInParams; lOutCmd: TSendCmdOutParams; lIdOutCmd: Pointer; lAttrOutCmd: Pointer; lThreshOutCmd: Pointer; Begin Memo1.Lines.Clear; [color=red]For i2 := 0 to 0 Do Begin[/color] bDfpDriveMap := 0; [color=red]lSmartHandle := CreateFile(PChar('\\.\PhysicalDrive' + IntToStr(i2)), GENERIC_READ Or GENERIC_WRITE, FILE_SHARE_READ Or FILE_SHARE_WRITE, Nil, OPEN_EXISTING, 0, 0);[/color] If ( lSmartHandle = INVALID_HANDLE_VALUE ) Then Begin lError := GetLastError; If ( Win32Platform = VER_PLATFORM_WIN32_WINDOWS ) Then Memo1.Lines.Add(format('Unable to open SMARTVSD, error code: 0x%.08X (%s)', [lError, SysErrorMessage(lError)])) Else If ( Win32Platform = VER_PLATFORM_WIN32_NT ) Then Memo1.Lines.Add(format('Unable to open physical drive, error code: 0x%.08X (%s)', [lError, SysErrorMessage(lError)])); Exit; End Else Memo1.Lines.Add('SMART interface opened...'); GetMem(lIdOutCmd, SizeOf(TSendCmdOutParams) + IDENTIFY_BUFFER_SIZE - 1); GetMem(lAttrOutCmd, SizeOf(TSendCmdOutParams) + READ_ATTRIBUTE_BUFFER_SIZE - 1); GetMem(lThreshOutCmd, SizeOf(TSendCmdOutParams) + READ_THRESHOLD_BUFFER_SIZE - 1); Try If GetSMARTVersionInfo(lSmartHandle, lVersionInfo) Then Begin Memo1.Lines.Add('DFP_GET_VERSION returned:'); Memo1.Lines.Add(format(' bVersion = %d', [lVersionInfo.bVersion])); Memo1.Lines.Add(format(' bRevision = %d', [lVersionInfo.bRevision])); Memo1.Lines.Add(format(' fCapabilities = 0x%.08x', [lVersionInfo.fCapabilities])); Memo1.Lines.Add(format(' bReserved = 0x%x', [lVersionInfo.bReserved])); Memo1.Lines.Add(format(' bIDEDeviceMap = 0x%x', [lVersionInfo.bIDEDeviceMap])); // Memo1.Lines.Add(format(' cbBytesReturned = %d', cbBytesReturned); End Else Memo1.Lines.Add('DFP_GET_VERSION failed.'); For i := 0 To MAX_IDE_DRIVES Do Begin // // If there is a IDE device at number "i" issue commands // to the device. // If ( ( ( lVersionInfo.bIDEDeviceMap Shr i ) And 1 ) <> 0 ) Then Begin // // Try to enable SMART so we can tell if a drive supports it. // Ignore ATAPI devices. // If ( ( ( lVersionInfo.bIDEDeviceMap Shr i ) And $10 ) = 0 ) Then Begin FillChar(lInCmd, SizeOf(lInCmd), 0); FillChar(lOutCmd, SizeOf(lOutCmd), 0); If ( DoEnableSMART(lSmartHandle, @lInCmd, @lOutCmd, i, lBytesReturned) ) Then Begin Memo1.Lines.Add(format('SMART enabled on drive: %d', [i])); // // Mark the drive as SMART enabled // bDfpDriveMap := bDfpDriveMap Or ( 1 Shl i ); End Else Begin Memo1.Lines.Add(format('SMART Enable Command Failed, Drive: %d', [i])); Memo1.Lines.Add(format(' DriverStatus: bDriverError=0x%.08X, bIDEStatus=0x%.08X', [ lOutCmd.DriverStatus.bDriverError, lOutCmd.DriverStatus.bIDEStatus])); End; Memo1.Lines.Add(Format(' cbBytesReturned: %d', [lBytesReturned])); End; // // Now, get the ID sector for all IDE devices in the system. // If the device is ATAPI use the IDE_ATAPI_ID command, // otherwise use the IDE_ID_FUNCTION command. // If ( ( ( lVersionInfo.bIDEDeviceMap Shr i ) And $10 ) <> 0 ) Then bIDCmd := IDE_ATAPI_ID Else bIDCmd := IDE_ID_FUNCTION; FillChar(lInCmd, SizeOf(lInCmd), 0); FillChar(lIdOutCmd^, SizeOf(TSendCmdOutParams) + IDENTIFY_BUFFER_SIZE - 1, 0); If ( DoIDENTIFY(lSmartHandle, @lInCmd, lIdOutCmd, bIDCmd, i, lBytesReturned) ) Then Begin DisplayIdInfo(Memo1.Lines, PIDSector(@(PSendCmdOutParams(lIdOutCmd)^.bBuffer[0]))^, lInCmd, bIDCmd, bDfpDriveMap, i); End Else Begin Memo1.Lines.Add(format('Identify Command Failed on Drive: %d', [i])); Memo1.Lines.Add(format(' DriverStatus: bDriverError=0x%.08X, bIDEStatus=0x%.08X', [ PSendCmdOutParams(lIdOutCmd)^.DriverStatus.bDriverError, PSendCmdOutParams(lIdOutCmd)^.DriverStatus.bIDEStatus])); End; Memo1.Lines.Add(format(' cbBytesReturned: %d', [lBytesReturned])); End; End; // // Loop through all possible IDE drives and send commands to the ones that support SMART. // For i := 0 To MAX_IDE_DRIVES Do Begin If ( ( ( bDfpDriveMap Shr i ) And 1 ) <> 0 ) Then Begin FillChar(lAttrOutCmd^, SizeOf(TSendCmdOutParams) + READ_ATTRIBUTE_BUFFER_SIZE - 1, 0); FillChar(lThreshOutCmd^, SizeOf(TSendCmdOutParams) + READ_THRESHOLD_BUFFER_SIZE - 1, 0); lSuccess := DoReadAttributesCmd( lSmartHandle, @lInCmd, lAttrOutCmd, i); If ( Not lSuccess ) Then Begin Memo1.Lines.Add(format('SMART Read Attr Command Failed on Drive: %d', [i])); Memo1.Lines.Add(format(' DriverStatus: bDriverError=0x%.08X, bIDEStatus=0x%.08X', [ PSendCmdOutParams(lAttrOutCmd)^.DriverStatus.bDriverError, PSendCmdOutParams(lAttrOutCmd)^.DriverStatus.bIDEStatus])); End // ReadAttributes worked. Try ReadThresholds. Else If ( Not DoReadThresholdsCmd( lSmartHandle, @lInCmd, lThreshOutCmd, i) ) Then Begin lSuccess := False; Memo1.Lines.Add(format('SMART Read Thresh Command Failed on Drive: %d', [i])); Memo1.Lines.Add(format(' DriverStatus: bDriverError=0x%.08X, bIDEStatus=0x%.08X', [ PSendCmdOutParams(lAttrOutCmd)^.DriverStatus.bDriverError, PSendCmdOutParams(lAttrOutCmd)^.DriverStatus.bIDEStatus])); End Else lSuccess := True; // // The following report will print if ReadAttributes works. // If ReadThresholds works, the report will also show values for // Threshold values. // If ( lSuccess ) Then Begin DoPrintData( Memo1.Lines, @(PSendCmdOutParams(lAttrOutCmd)^.bBuffer[0]), @(PSendCmdOutParams(lThreshOutCmd)^.bBuffer[0]), i); End; End; End; Finally [color=red]CloseHandle(lSmartHandle);[/color] FreeMem(lIdOutCmd); FreeMem(lAttrOutCmd); FreeMem(lThreshOutCmd); End; [color=red]Memo1.Lines.Add(''); Memo1.Lines.Add(''); Memo1.Lines.Add(''); End;[/color] End; End. [add] und ihr seid euch sicher, daß ![]() Bit 0 = Primary Master
Bit 1 = Primary Slave Bit 2 = Secondary Master Bit 3 = Secondary Slave meine S-ATA is ja an Port 0 und in der Systemsteuerung steht sie als "Primary Master", aber SMARTAppD7 meint "SMART enabled on drive: 2" ... also "Secondary Master" Bei der IDE stimmt die 0.
Code:
SMART interface opened...
DFP_GET_VERSION returned: bVersion = 1 bRevision = 1 fCapabilities = 0x00000007 bReserved = 0x0 bIDEDeviceMap = 0x4 SMART enabled on drive: 2 cbBytesReturned: 16 Drive 2 is an IDE Hard drive that supports SMART #Cylinders: 16383, #Heads: 16, #Sectors per Track: 63 IDE TASK FILE REGISTERS: bFeaturesReg = 0x0 bSectorCountReg = 0x1 bSectorNumberReg = 0x1 bCylLowReg = 0x0 bCylHighReg = 0x0 bDriveHeadReg = 0xA0 Status = 0xEC Model number: Maxtor 6V250F0 Firmware rev: VA11163 Serial number: V594J4NG cbBytesReturned: 528 Data for Drive Number 2 Attribute Structure Revision Threshold Structure Revision 32 32 -Attribute Name- -Attribute Value- -Threshold Value- 03 Spin Up Time 191 63 04 Start/Stop Count 253 0 05 Reallocated Sector Count 253 63 07 Seek Error Rate 253 0 08 Seek Time Performance 249 187 09 Power On Hours Count 253 0 0A Spin Retry Count 253 157 0B Calibration Retry Count 253 223 0C Power Cycle Count 253 0 BD (Unknown attribute) 100 0 BE (Unknown attribute) 50 0 C0 (Unknown attribute) 253 0 C1 (Unknown attribute) 253 0 C2 (Unknown attribute) 48 0 C3 (Unknown attribute) 253 0 C4 (Unknown attribute) 253 0 C5 (Unknown attribute) 253 0 C6 (Unknown attribute) 253 0 C7 (Unknown attribute) 199 0 C8 (Unknown attribute) 253 0 C9 (Unknown attribute) 253 0 CA (Unknown attribute) 253 0 CB (Unknown attribute) 253 180 CC (Unknown attribute) 253 0 CD (Unknown attribute) 253 0 CF (Unknown attribute) 253 0 D0 (Unknown attribute) 253 0 D2 (Unknown attribute) 253 0 D3 (Unknown attribute) 253 0 D4 (Unknown attribute) 253 0 SMART interface opened... DFP_GET_VERSION returned: bVersion = 1 bRevision = 1 fCapabilities = 0x00000007 bReserved = 0x0 bIDEDeviceMap = 0x1 SMART enabled on drive: 0 cbBytesReturned: 16 Drive 0 is an IDE Hard drive that supports SMART #Cylinders: 16383, #Heads: 16, #Sectors per Track: 63 IDE TASK FILE REGISTERS: bFeaturesReg = 0x0 bSectorCountReg = 0x1 bSectorNumberReg = 0x1 bCylLowReg = 0x0 bCylHighReg = 0x0 bDriveHeadReg = 0xA0 Status = 0xEC Model number: MAXTOR 4K040H2 Firmware rev: A08.150B Serial number: 572123615033 cbBytesReturned: 528 Data for Drive Number 0 Attribute Structure Revision Threshold Structure Revision 11 11 -Attribute Name- -Attribute Value- -Threshold Value- 01 Raw Read Error Rate 100 20 03 Spin Up Time 87 20 04 Start/Stop Count 96 8 05 Reallocated Sector Count 98 20 07 Seek Error Rate 100 23 09 Power On Hours Count 72 1 0A Spin Retry Count 100 0 0B Calibration Retry Count 100 20 0C Power Cycle Count 96 8 0D (Unknown attribute) 100 23 C2 (Unknown attribute) 85 42 C3 (Unknown attribute) 100 0 C4 (Unknown attribute) 100 20 C5 (Unknown attribute) 100 20 C6 (Unknown attribute) 100 0 C7 (Unknown attribute) 126 0 Unable to open physical drive, error code: 0x00000002 (Das System kann die angegebene Datei nicht finden)
Ein Therapeut entspricht 1024 Gigapeut.
|
![]() |
Ansicht |
![]() |
![]() |
![]() |
ForumregelnEs 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
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
![]() |
![]() |