能力值:
( LV2,RANK:10 )
|
-
-
2 楼
这样也不行 请高手指点一下 谢谢
procedure ChangeByteOrder( var Data; Size : Integer );
var
ptr : PChar;
i : Integer;
c : Char;
begin
ptr := @Data;
for i := 0 to (Size shr 1)-1 do
begin
c := ptr^;
ptr^ := (ptr+1)^;
(ptr+1)^ := c;
Inc(ptr,2);
end;
end;
function GetDriveGeometry():pchar; stdcall;
const IDENTIFY_BUFFER_SIZE = 512;
type
TSendCmdOutParams = packed record
cBufferSize : DWORD;
DriverStatus : TDriverStatus;
bBuffer : Array[0..0] of BYTE;
end;
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;
bReserved : Array[0..127] of BYTE;
end;
PIdSector = ^TIdSector;
var
hDevice: THandle;
dTemp: DWord;
stin:tSENDCMDINPARAMS;
stout:Array [0..(SizeOf(TSendCmdOutParams)+IDENTIFY_BUFFER_SIZE-1)-1] of Byte;
IdOutCmd : TSendCmdOutParams absolute stout;
begin
Result:=nil;
hDevice:= CreateFile('\\.\PhysicalDrive0',GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,
nil,OPEN_EXISTING,0,0);
if hDevice = INVALID_HANDLE_VALUE then showmessage('open disk fail');
FillChar(stin,SizeOf(TSendCmdInParams)-1,#0);
FillChar(stout,SizeOf(stout),#0);
dtemp:=0;
stin.irDriveRegs.bSectorCountReg :=1;
stin.irDriveRegs.bSectorNumberReg:=1;
stin.irDriveRegs.bDriveHeadReg :=$A0;
stin.irDriveRegs.bCommandReg:=$0ec;
stin.cBufferSize :=IDENTIFY_BUFFER_SIZE;
if not DeviceIoControl(hDevice,$0007C088,@stIn,sizeof(SENDCMDINPARAMS)-1,@stOut,sizeof(stout),dtemp,nil) then
showmessage(inttostr(getlasterror()));
with PIdSector(@IdOutCmd.bBuffer)^ do begin
ChangeByteOrder(stout, SizeOf(stout));
(PChar(@stout)+SizeOf(stout))^:= #0;
Result := PChar(@stout);
end;
CloseHandle(hDevice);
end;
|
|
|