Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2009, 06:28 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default Anybody know a free code?

Anybody know a free code to get the hard disk manufacture serial number that works with XP and Vista?

Regards,
Abdulaziz Jasser
Reply With Quote
  #2  
Old 04-08-2009, 09:22 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default RE: Anybody know a free code?

You could try this:

[delphi]
function GetHardDiskSerial(const DriveLetter: Char): string;
var
NotUsed: DWORD;
VolumeFlags: DWORD;
VolumeInfo: array[0..MAX_PATH] of Char;
VolumeSerialNumber: DWORD;
begin
GetVolumeInformation(PChar(DriveLetter + ':\'),
nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed,
VolumeFlags, nil, 0);
Result := Format('Label = %s VolSer = %8.8X',
[VolumeInfo, VolumeSerialNumber])
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetHardDiskSerial('c'));
end;
[/delphi]

I tested it on Vista Ultimate x64 bit and Windows XP...

"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #3  
Old 04-08-2009, 09:41 PM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Anybody know a free code?

Thank you nester261 for trying to help. But this is the volume number. There is a big difference between volume number and the real manufacture serial number.

Regards,
Abdulaziz Jasser
Reply With Quote
  #4  
Old 04-08-2009, 11:22 PM
nester261 nester261 is offline
Moderator
 
Join Date: Jan 2004
Location: UK
Posts: 618
Default RE: Anybody know a free code?

Hi,

Sorry about that, I did mangage to find this but is only for IDE HDD:

http://www.delphi3000.com/articles/article_1164.asp?SK=

"Where there's a will, there's always a way."

-- The Hon Robert Nester Marley O.M. - aka Bob Marley!
Reply With Quote
  #5  
Old 04-11-2009, 11:20 PM
develyoy develyoy is offline
Senior Member
 
Join Date: Nov 2007
Posts: 628
Default RE: Anybody know a free code?

I've done something similar once with WMI
http://www.google.com/search?q=delphi+wmi
Reply With Quote
  #6  
Old 04-13-2009, 08:02 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default RE: Anybody know a free code?

WMI is for sure is the best choice. Thank you develyoy.

Regards,
Abdulaziz Jasser
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:17 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.