For a requirement to generate per-PC license keys, I need some code which will return a stable and (near) unique key on any PC. It doesn't have to be guaranteed unique, but close. It does need to be reasonably stable though, so that a given PC always generates the same result unless the hardware is substantially changed.
This is for a Windows application, using wxWidgets but a Win32 or other option is fine.
I was thinking about MAC address but what about laptops which can routinely disable the network card in power-saving mode? I came across GetCurrentHwProfile but it doesn't quite look like what I want?
A unique identifier (UID) is a numeric or alphanumeric string that is associated with a single entity within a given system. UIDs make it possible to address that entity, so that it can be accessed and interacted with.
Each device in Windows has it's own unique identifier known as the Hardware ID. The Device ID is the identifier of the PC itself.
On a desktop computer, this sticker is usually on the side or back of the computer. Laptop computers often have this sticker on the bottom of the computer. If you still cannot find the product number and your computer came with Microsoft Windows, contact your computer manufacturer to purchase a new number.
Click Start, right-click Computer, and then click Properties. The computer name appears under Computer name, domain, and workgroup settings.
One idea I had a while back for this is to use CryptProtectData as a way to identify a machine. Behind-the-scenes in that API, Microsoft has done what you're looking for. I never tested it though and I'm curious if it's actually viable.
Basically you would encode a constant magic value with CryptProtectData
with CRYPTPROTECT_LOCAL_MACHINE
, and the result is your machine ID.
I think there no really easy and unique method so far discovered here.
Regards Mickel.
For a pretty brain dead test I am using the ProductID code of the OS and the computer name - both extracted from the registry. Not really secure, but its all pretend security anyway.
edit
To answer John's question about what keys I am reading:
SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductID
SYSTEM\CurrentControlset\Control\ComputerName\ComputerName\ComputerName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With