Delphi Get Serial Number Hardisk
Delphi Get Serial Number Hardisk
var
hDevice : THandle;
cbBytesReturned : DWORD;
// ptr : PChar;
SCIP : TSendCmdInParams;
aIdOutCmd : Array [0..(SizeOf(TSendCmdOutParams)+IDENTIFY_BUFFER_SIZE-1)-1]
of Byte;
IdOutCmd : TSendCmdOutParams absolute aIdOutCmd;
or ShowMessage:
ShowMessage( GetHDDSerialNumber(0));
Code:
function GetHardDiskSerial(const DriveLetter: char): string;
var
NotUsed : dWord;
VolumeFlags : dWord;
VolumeInfo : array[0..MAX_PATH] of char;
VolumeSerialNumber: dWord;
begin
GetVolumeInformation(PChar(DriveLetter + ':\'),
VolumeInfo, SizeOf(VolumeInfo),
@VolumeSerialNumber, NotUsed,
VolumeFlags, nil, 0);
result := Format('%14s | %X |',
[VolumeInfo, VolumeSerialNumber])
// result := IntToStr(VolumeSerialNumber);
end;
This function retrieves a serial number of HDD but it isn't the one provided by the manufacturer.
I say that because if I run this function it returns one serial number but if I format the drive, this
serial number is changing. It is like disk_label (changes on every format). I need the serial
number (unique for every HDD), which is eventually stored in a ROM or something...
Patcher (.pas) unit for Delphi (makes patching easier)
No more downloadable,
because it's here:
PATCHER.PAS
unit Patcher;
interface
uses
SysUtils;
type
ByteArray = Array of Byte;
TPatches = Array of Record
Offset: Cardinal;
Bytes: ByteArray;
end;
TPatcher = class
private
fInit: Boolean;
fHandle: Integer;
public
constructor Create( FileName: String );
destructor Destroy; override;
procedure Add( Offset: Cardinal; Bytes: ByteArray );
procedure PatchFile;
end;
implementation
var
Patches: TPatches;
destructor TPatcher.Destroy;
begin
if fInit = True then
begin
fInit := False;
FileClose( fHandle );
SetLength( Patches, 0 );
inherited Destroy;
end;
end;
procedure TPatcher.PatchFile;
var
I, X, Size: Cardinal;
Line: String;
begin
if fInit = True then
begin
Size := Length( Patches );
if Size > 0 then
begin
for I := 0 to ( Size - 1 ) do
begin
FileSeek( fHandle, Patches[I].Offset, 0 );
Line := String( Patches[I].Bytes );
for X := 1 to ( Length( Line ) - 1 ) do
FileWrite( fHandle, Line[X], 1 );
end;
SetLength( Patches, 0 );
end;
end;
end;
end.
EXAMPLE
Code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, Patcher;
type
TForm1 = class(TForm)
Button1: TButton;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.
CRACK BOX