Agree with solution #1 - a better idea is to use the MAC address. This is not completely hack proof but at least it is always there and is meant to be unique. You can use WinApi GetAdaptersInfo function for example.
void GetMacAddress()
{
CString m_MacAddressStr;
IP_ADAPTER_INFO AdapterInfo[16]; DWORD dwBufLen = sizeof(AdapterInfo); DWORD dwStatus = GetAdaptersInfo(AdapterInfo, &dwBufLen);
if (dwStatus != ERROR_SUCCESS)
{
return;
}
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; do
{
m_MacAddressStr.Format("%02X-%02X-%02X-%02X-%02X-%02X",
(int)pAdapterInfo->Address[0], (int)pAdapterInfo->Address[1],
(int)pAdapterInfo->Address[2], (int)pAdapterInfo->Address[3],
(int)pAdapterInfo->Address[4], (int)pAdapterInfo->Address[5]);
pAdapterInfo = pAdapterInfo->Next;
} while (pAdapterInfo);
}
By the way, if you have a serial port on the computer on which you are running your code, the chances are you will get the PPP (point to point protocol) adapter first in this list of adapters. Which happens to be "44-45-53-54-00-00". So you should skip it and look for a real MAC address of the first network interface. Most modern PCs will have 2 or more (WiFi and Ethernet, etc).