Victor
Victor

Reputation: 771

What is a easy way to generate a GUID for the current machine in C++?

I am currently developing a first-person-shooter.

I would like to know if there is a way to generate a GUID that will always return the same value for the same machine, but will be different on another machine.

I need to do this generation to effectively ban troublesome users.

I want it to work on both Microsoft Visual C++ and g++.

Upvotes: 1

Views: 963

Answers (4)

rushman
rushman

Reputation: 562

There's also the TMID in HKEY_CLASSES_ROOT. Windows only though.

Upvotes: 0

Colen
Colen

Reputation: 13918

You could read the MachineGuid key at the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography registry key.

That would work on Windows, but you'd need an alternate method for other OS's.

Upvotes: 1

Marc DiMillo
Marc DiMillo

Reputation: 513

I would second the vote on the MAC address, because every MAC address is unique when manufactured, but then you run the issue of spoofing. I recommend you base it on multiple values such as the volume serial number, CPU model/stepping, MAC Address, and the disk manufacturer just as an example. It's up to you, but try to avoid relying on just a single value as that could always change, but then again, the GUID would change if any of your identifying factors changed, so you would need to pick some kind of persistent value between machines. Something like the product key, or product id rather might be a better choice, but im not sure if thats easily accessible if at all.

Upvotes: 1

Joshua Clark
Joshua Clark

Reputation: 1356

You could use the MAC address.

A way to do it is described here.

Upvotes: 0

Related Questions