Creating a hardware computer identifier

I had a question about creating a specific computer ID for licensing purposes. Preferably, this identifier should be hardware based and therefore should not be changed if the user reformatted, for example. In addition, it should not be easy for the user (or, preferably, even impossible) to change the information from which the identifier is generated. Currently, I have only two components that I combine, the standard and functional CPUID flags, as well as the geometry and overall size of the first physical disk in the machine. While this seems good for most ordinary PCs, many netbooks, for example, are manufactured using the same hardware, and so you will get the same identifier for many machines in this case.Can any of you suggest another hardware component that I could use?

I have two requirements:

  • He should not use WMI.

  • It should work in a large number of situations (including for users with unlimited privileges). I was thinking about using a series of physical disk, but it is hard to find if the user is not in administrator mode.

I work in C ++ on Windows.

Thanks in advance for any suggestions.

Yours faithfully,

Philip Bennefall

+5
source share
6 answers

You can use the first MAC address assigned by the hardware manufacturer and it will never change.

Something like that:

/** 

  return string containing first MAC address on computer

 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 );
}

IMHO, , , , - . , , , , , , .

, , .

, , .. , , - , , , .

MAC-, . , . , .

(, ethernet wireless), ( ?). , , , :

/**

  The MAC addresses of ethernet network cards present on computer

  @param[out] vMAC vector of strings containing MAC addresses in XX-XX-XX-XX-XX-XX format

  returns empty vector on error

  See discussion of this 
  http://stackoverflow.com/questions/6131123/generating-hardware-based-computerid/6131231#6131231

*/

void cLicenser::GetMac( vector < string >& vMac )
{
    vMac.clear();
    char data[4096];
    ZeroMemory( data, 4096 );
     unsigned long  len = 4000;
    PIP_ADAPTER_INFO pinfo = ( PIP_ADAPTER_INFO ) data;

    DWORD ret = GetAdaptersInfo( pinfo, &len );
    if( ret != ERROR_SUCCESS )
        return;

    while ( pinfo ) {
    if( pinfo->Type == MIB_IF_TYPE_ETHERNET ) (
            // ignore software loopbacks and other strange things that might be present
        continue;
        char sbuf[20];
        string sret;
        for(int k = 0; k < 5; k++ ) {
            sprintf(sbuf,"%02X-",pinfo->Address[k]);
            sret += sbuf;
        }
        sprintf(sbuf,"%02X",pinfo->Address[5]);
            sret += sbuf;
        vMac.push_back( sret );
            }
        pinfo = pinfo->Next;
    }

}
+4

- . , . CPU CPUID, , . , , . , , Intel Celeron series . ( Intel) , .

- , , .

/ MAC- CPU MB GUID. , , . , - , ID , .

, . , , Microsoft.

Microsoft , , ​​, , OS/Office. ( , 4 ), , Microsoft Windows.

+3

, GUID , . , , , . , GUID .

, MAC- ( MAC- ).

+2

, Microsoft .

doo-dad, a 'dongle' . , ! .

, , , , .

+1

One of many options is to use a CPU identifier. Better than a Windows registry or network card, for example. You do not want users to bother you every time they change their network card, etc. I think a cpuid project can be used as an example and start a point.

0
source

All Articles