Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial number for hardware 1

Status
Not open for further replies.

costea

Programmer
Aug 21, 2003
2
MD
I need something like a serial number of the Hardware that my program could get from any hardware lik HDD, Screen or anything, If you have an Ideea about what i am talkin, respond...
 
It depends on what you want to do.

If all you want is the serial number of the Hard Drive for example simply use GetVolumeInformation()

If you want the MAC address of your network card it's a little more involved.

You will need the following API functions :
Netbios (NCB pncb);
CopyMemory (PVOID hpvDest,LONG hpvSource LONG cbcopy);
GetProcessHeap();
HeapAlloc (LONG hHeap,LONG dwFlags, LONG dwBytes);
HeapFree (LONG hHeap LONG dwFlags, LPVOID lpMem);

If you can't be bothered or want to see an example (albeit in VB) an open source sample is available here <
Hope this helps.
 
It isn't as involved as is made out.

The MAC address just needs a call to UuidCreateSequential. The last 6 bytes of the resulting GUID represent the MAC address.

Note that you may find solutions suggesting the use of CoCreateGuid. However, this is just a wrapper for UuidCreate which, as of W2000, no longer returns the MAC portion. So, on the older OSs you can use CoCreateGuid or UuidCreate, and on W2000/XP/W2003 use UuidCreateSequential
 
Didn't know that ... thanks.

As an addendum it appears that you should use UuidCreateSequential for XP,2000 and UuidCreate for 9x/ME
 
I think I said that in my second paragraph. But it is worth repeating.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top