nuttyprofessor
asked on
HDD serial number
How do I obtain the serial number of the PC's hard disk, or any other number/string which is unique to that particlar machine?
You can also use some BIOS information as unique keys!
To get the BIOS info use one of the following functions:
//FUNCTION TO GET COMPLETE BIOS INFO AS TEXT
function GetBiosInfoAsText: string;
var
p, q: pchar;
begin
q := nil;
p := PChar(Ptr($FE000));
repeat
if q <> nil then begin
if not (p^ in [#10, #13, ' '..'~' , '?' , '?' ]) then begin
if (p^ = #0) and (p - q >= 8) then begin
Result := Result + TrimRight(String(q)) + #13#10;
end;
q := nil;
end;
end else
if p^ in ['!'..'~' , '?' , '?' ] then
q := p;
inc(p);
until p > PChar(Ptr($FFFFF));
Result := TrimRight(Result);
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
memo1.Lines.text:=GetBiosI nfoAsText;
end;
//SIMPLE CODE TO GET ONLY THE BIOS DATE
procedure TForm1.Button1Click(Sender : TObject);
begin
edit1.text:=String(PChar(P tr($FFFF5) ));
end;
Hope this helps!
VSF
www.victory.hpg.com.br
To get the BIOS info use one of the following functions:
//FUNCTION TO GET COMPLETE BIOS INFO AS TEXT
function GetBiosInfoAsText: string;
var
p, q: pchar;
begin
q := nil;
p := PChar(Ptr($FE000));
repeat
if q <> nil then begin
if not (p^ in [#10, #13, ' '..'~' , '?' , '?' ]) then begin
if (p^ = #0) and (p - q >= 8) then begin
Result := Result + TrimRight(String(q)) + #13#10;
end;
q := nil;
end;
end else
if p^ in ['!'..'~' , '?' , '?' ] then
q := p;
inc(p);
until p > PChar(Ptr($FFFFF));
Result := TrimRight(Result);
end;
procedure TForm1.Button1Click(Sender
begin
memo1.Lines.text:=GetBiosI
end;
//SIMPLE CODE TO GET ONLY THE BIOS DATE
procedure TForm1.Button1Click(Sender
begin
edit1.text:=String(PChar(P
end;
Hope this helps!
VSF
www.victory.hpg.com.br
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hello
This is the Volume serial for partition "c", no not the hard diks serial number, so every time you format this partition it will change, even there are some utilities could change the Volume number, or you can change it also from code, so this way it will not be good if you want to do that for software protection
look at this link for
Getting the BIOS serial number
http://www.latiumsoftware.com/en/delphi/00050.php3
Best regards
Mohammed Nasman
This is the Volume serial for partition "c", no not the hard diks serial number, so every time you format this partition it will change, even there are some utilities could change the Volume number, or you can change it also from code, so this way it will not be good if you want to do that for software protection
look at this link for
Getting the BIOS serial number
http://www.latiumsoftware.com/en/delphi/00050.php3
Best regards
Mohammed Nasman
I'm glad to help!
Please show your support visiting my homepage!
www.victory.hpg.com.br
www.enge.cjb.net
VSF
UIN:14016999
Please show your support visiting my homepage!
www.victory.hpg.com.br
www.enge.cjb.net
VSF
UIN:14016999
Var
a,b : Integer;
buffer : array[0..255] of char;
B1 : PChar;
SerialNumber : Dword;
Begin
New(B1);
B1 := StrPCopy(B1, DriveLatter + ':\');
GetVolumeInformation(B1, Buffer,
sizeof(buffer),@SerialNumb
Result := SerialNumber;
Dispose(B1);
End;
This should do it!
VSF
www.victory.hpg.com.br