unique device attributes

  • Thread starter Thread starter Joe Audette
  • Start date Start date
J

Joe Audette

I'm looking for a way to calculate a system id for devices
that don't support the device id. I know how to determine
the OS and total physical memory but I'm looking for
something relatively unique to the hardware or user.
Is there a way to get the name of the user or the serial
number for the OS or anything else that is relatively
unique to the device or user?

Thanks for any suggestions.

Joe Audette
 
If the device has Ethernet, the Ethernet address (not the IP address), must
be globally unique.

Paul T.
 
Paul,

Thanks for the response.

I can't expect that all devices where my app would be
deployed would have an Ethernet address. I guess you're
talking about the MAC address of the Ethernet adapter. I'd
be interested if you have a code sample of how to retrieve
the MAC address on devices that do have an Ethernet
adapter but I still need something else for the devices
that don't have an Ethernet adapter and don't support the
device id.

Thanks,

Joe
 
Joe,

Something like this retrieves the Ethernet address, if the device has the
IpHlpAPI on it:

-----

if ( GetAdaptersInfo( ip, &IP_INFO_SIZE ) == ERROR_SUCCESS )
{
IP_ADAPTER_INFO *ipinfo = ip;

do
{
TCHAR s[ 256 ];
MultiByteToWideChar( CP_ACP, 0, ipinfo->AdapterName, -1,
s, sizeof( s ) / sizeof( s[0] ) );

// Check for match. If match, return the Ethernet address.
if ( !_tcsicmp( fKey, s ) )
{
// Get Ethernet address.
_stprintf( enet, _T( "%02x.%02x.%02x.%02x.%02x.%02x" ),
ipinfo->Address[ 0 ],
ipinfo->Address[ 1 ],
ipinfo->Address[ 2 ],
ipinfo->Address[ 3 ],
ipinfo->Address[ 4 ],
ipinfo->Address[ 5 ] );
break;
}

ipinfo = ipinfo->Next;
} while ( ipinfo );
}

// Done with it, now.
delete [] ip;

-----

Note that this is looking for a specific adapter name, in fKey, but you
should be able to use it unchanged, otherwise.

Paul T.
 
Back
Top