techno
techno

Reputation: 6526

Storing Licensing Information in HKEY_CURRENT_USER Branch of the Registry in c#

I'm trying to save user registration data to the registry in c#. But without administrative rights i cannot access HKEY_LOCAL_MACHINE. I don't have admin rights, so i decide to store it in HKEY_CURRENT_USER branch.

Is this approach good, i.e. if a user registers the product and he switches the account in windows, the application will be unregistered. Does commercial softwares use HKEY_CURRENT_USER branch to store license key of the user. Since the license is for a single user is there a problem if i only allow a single user(a windows user) to use the key preventing other users from its use.

Upvotes: 0

Views: 889

Answers (3)

Bali C
Bali C

Reputation: 31251

I tend to stay away from the registry unless I can help it. This way would be very easy to pirate if you are selling your product, although there may be no possible pirate-proof ways I wouldn't recommend using the registry.

An approach I have used before is to save the license key in your app's app.config. Then it is compiled with the app so you don't have anything computer specific to depend on. When your app is activated the key is saved in the config file and on each opening of the app it just does a bool check to see if it is valid.

This way also makes it harder for computer savvy users to pirate your software.

Hope this helps.

Upvotes: 0

You can elevate the process when the user is activating the product so that the write access to HKLM is allowed.

Depending on your license model I would recommend registering the product per machine as in this way different users can all use the license.

But if you want to allow only the original user to use the license then HKCU is fine.

Upvotes: 0

Tigran
Tigran

Reputation: 62265

Why do not save some key file with user specific license agreement in

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)?

The user that runs your program has access to that location granted by system itself.

Upvotes: 3

Related Questions