HOW TO get Hareware ID by using API

Started by
7 comments, last by MaulingMonkey 18 years, 3 months ago
HOW TO get Hareware ID by using API
Advertisement
Which hardware ID? Which API?
By calling a function.

"Which function?"
Which API/Hardware ID?

"API X, Hardware ID Y"
Likely answers:
Google Search: C++ X Y ID
MSDN Search: C++ X Y ID
Note: Substitute C++ for language of your choice.

For guessing two steps ahead, I win!

As a prize... I recieve... a door!!!

I'm going to go install that door now. Finally get some privacy to change/blare loud music.

"I don't suffer from insanity, I enjoy every last minute of it!"

~Mike
API = WINDOWS API,
HARDWARE = Network Adapter or Disk
I hope you can understand what I mean.
What ID?
What do you mean by disk? CD? Harddisk? Floppy?
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
If I read you correctly, you want some form of unique identifier for the computer, generated by hashing the disk ID / NIC ID, maybe a couple of other values.

Correct?

The following source shows how to extract eh NIC information.. maybe someone else has DiskID info?

I'd be carefull about trusting it too far though; the user will hate you if installing a new network card disables his game. NICs can also be faked using programs that overwrite the NIC ID.


 // Retrieve network interface information  //  DWORD sizeReq = 0 ;  PMIB_IFTABLE pInfo = NULL;  // Get size information  ::GetIfTable(NULL, &sizeReq, FALSE) ;  // Allocate required memory  pInfo = (PMIB_IFTABLE)( new BYTE [sizeReq] );  memset (pInfo, 0, sizeReq) ;  DWORD sizeToUse = sizeReq ;  // Retrieve network interface information  bool result = ( ::GetIfTable( (PMIB_IFTABLE)pInfo, &sizeToUse, FALSE) == NO_ERROR );  if( !result )  {    delete [] (PMIB_IFTABLE)pInfo;    pInfo = NULL;    _LOG(MSG_WARNING, "Couldn't retrieve network interface information!");    return ;  }  m_NIC = "";  // Print all interface information  for( unsigned int index = 0; index <((PMIB_IFTABLE)pInfo)->dwNumEntries; index ++ )  {    // Get interface description    MIB_IFROW& details = ((PMIB_IFTABLE)pInfo)->table[index];		// Format physical address    char macStr[50];	memset(macStr, 0, sizeof(macStr));    for (DWORD j = 0 ; j < details.dwPhysAddrLen ; ++j)    {      sprintf( &macStr[j*3], "%02X-", details.bPhysAddr[j] );    }    macStr[j*3-1] = '\0';	m_NIC = macStr;	return;

Allan

[Edited by - __ODIN__ on January 1, 2006 10:56:44 AM]
------------------------------ BOOMZAPTry our latest game, Jewels of Cleopatra
Thanks for you help.
Then how can I get harddisk ID?
Quote:Original post by Robinhood
Then how can I get harddisk ID?


If you know Pascal, here's a page on it. Perhaps you can try and use assembly to emulate the same in C++.
Quote:Original post by MaulingMonkey
By calling a function.

"Which function?"
Which API/Hardware ID?

"API X, Hardware ID Y"
Likely answers:
Google Search: C++ X Y ID

Quote:Original post by Robinhood
Thanks for you help.
Then how can I get harddisk ID?

Google Search: C++ Windows Harddisk ID
First page has helpful stuff. Enjoy.

This topic is closed to new replies.

Advertisement