tags:

views:

234

answers:

3

Hi,

I would like to write a program that will identify a machine( for licensing purposes), I tought about getting the following information and to compile an xml file with this data:

  1. MAC address.
  2. CPU data (serial, manufacture, etc)
  3. MotherBoard Identification. (serial, manufacture, etc)

can someone refer me to a lib that provide such information - I write my program in c++ and have troubles to find such a lib.

Should I dig in the registry for this information?

Many Thanks, ofer

+3  A: 

Using WMI and getting the motherboard's serial number should be enough (the other options are less secure, since an old computer may not have a network adapter and/or the CPU can be changed more likely than the motherboard).

friol
It's worth noting that there may be multiple MAC addresses and they can change pretty frequently (e.g. a built-in WiFi card in a notebook, internally connected via USB, may totally disappear when not in use);
atzz
..and also that WMI can be disabled on a target machine, and is not present on older systems (Win2K, Win9x). But, still, WMI is the best bet in terms of compatibility.
atzz
A: 

GetAdaptersInfo() will give you the MAC address. Here's an example of how to use it for this purpose.

/** *************************************

  return string containing first MAC address on computer

  NOTE: requires adding Iphlpapi.lib to project

 */
string GetMac()
{
    char data[4096];
    ZeroMemory( data, 4096 );
     unsigned long  len = 4000;
    PIP_ADAPTER_INFO pinfo = ( PIP_ADAPTER_INFO ) data;
    char sbuf[20];
    string sret;

    DWORD ret = GetAdaptersInfo( pinfo, &len );
    if( ret != ERROR_SUCCESS )
     return string("**ERROR**");

    for(int k = 0; k < 5; k++ ) {
     sprintf(sbuf,"%02X-",pinfo->Address[k]);
     sret += sbuf;
    }
    sprintf(sbuf,"%02X",pinfo->Address[5]);
    sret += sbuf;

    return( sret );
}

For an example of a complete system to do this sort of thing, check out Manuele Sicuteri's article on CodeProject.

ravenspoint
A: 

Don't use WMI (slow, not installed on NT) Use standard Win32 apis

See news://comp.os.ms-windows.programmer.win32 where all this has been answered for decades (C /++ code)

Could you please elaborate? Links or essential excerpts would be appreciated. Your answer as-is is kinda useless.
atzz
Please can you point to specific win32 API which should be used?
Hemant