Unique indentifiers like MAC address, CPU serial number

Hi Guys,

 There are a lot of posts on EE and on the net as well ,that deal with how to get unique system identifiers of a system, but the problem is that none of these tips seem to work(like some work on win9x,but not on win2k)

Can anyone show me how to get the following in delphi
1.MAC address
2.motherboard serial number (or is it the BIOS number)
3.CPU serial number.

I have got a way to get the hard disk serial number,but thats not what I am looking for.

I promise to increase the points to 250,as I am short of points now.

Thanks

LVL 1
earlrainerAsked:
Who is Participating?
 
geobulConnect With a Mentor Commented:
Hi,

MAC Address example (works on Win2000 and XP for sure):

uses NB30;

function GetAdapterInfo(Lana: Char): String;
var
 Adapter: TAdapterStatus;
 NCB: TNCB;
begin
 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBRESET);
 NCB.ncb_lana_num := Lana;
 if Netbios(@NCB) <> Char(NRC_GOODRET) then
 begin
   Result := 'mac not found';
   Exit;
 end;

 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBASTAT);
 NCB.ncb_lana_num := Lana;
 NCB.ncb_callname := '*';

 FillChar(Adapter, SizeOf(Adapter), 0);
 NCB.ncb_buffer := @Adapter;
 NCB.ncb_length := SizeOf(Adapter);
 if Netbios(@NCB) <> Char(NRC_GOODRET) then
 begin
   Result := 'mac not found';
   Exit;
 end;
 Result :=
   IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +
   IntToHex(Byte(Adapter.adapter_address[5]), 2);
end;

function GetMACAddress: string;
var
 AdapterList: TLanaEnum;
 NCB: TNCB;
begin
 FillChar(NCB, SizeOf(NCB), 0);
 NCB.ncb_command := Char(NCBENUM);
 NCB.ncb_buffer := @AdapterList;
 NCB.ncb_length := SizeOf(AdapterList);
 Netbios(@NCB);
 if Byte(AdapterList.length) > 0 then
   Result := GetAdapterInfo(AdapterList.lana[0])
 else
   Result := 'mac not found';
end;

// usage
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(GetMACAddress);
end;

Regards, Geo
0
 
earlrainerAuthor Commented:
Hi Geo,

 On win2000 it gives an error saying netbios.dll not found.

I am not sure what this error is?
0
 
geobulCommented:
Hi,

Netbios function uses 'netapi32.dll' from your WINNT/system32 directory. I have that dll here in my Win2000.

Regards, Geo
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
earlrainerAuthor Commented:
Hi Geo,

 Thanks ,it works on Win2k ,
but some problem on win98 it returns 'mac not found'.

any idea about getting the motherboard\Bios serial nmber and the CPU number.

appreciate your help.Thanks
0
 
geobulCommented:
It might be. I have no 98 here for testing.

About BIOS and CPU: I'm sorry I have no idea. I'm not sure whether all CPUs have some kind of unique number.

Regards, Geo
0
 
tadooxCommented:
you said "how to get unique system identifiers"  i can say that MAC is not unique at least on xp you can easily scange it to that ever you like
so be carefull using it.
0
 
khanhson2Commented:
How can I get MAC on Win98?. Thanks!
0
 
JDuncanCommented:
If you use the code posted by gobul you will have to install (in network ) the netbios protocol parts in windows 98.

0
 
JDuncanCommented:
I forgot to mention you can also uuse this function to get your mac address

  g: TGUID;
  CoCreateGUID(g);

Use the bytes inreturn string bytes 2 to 7 as the address.

If you have a network card installed then the system uses the harware address from that card which is unique.

If you do not have a network card then the system generates its own internal number .
0
 
JDuncanCommented:
This must be the best explanation I have found on the net for this function

http://bdn.borland.com/article/0,1410,26040,00.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.