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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

geobulCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.