Search code examples
windowsregistry

Registry Alternative


I have a program that I sell. I have some basic protections in place to keep people from just copying the program folder and running the program. Right now I am storing keys, mainly used for tracking installation registration (which is tied into an encrypted license system).

So I actually WANT to store something in a semi-hard to find and edit location, that is global to the machine (HKEY_LOCAL_MACHINE), not a specific user of that machine (I can't use the users folder). All other application settings are stored either per user or per machine with either the exe or in the users folders, so it is just these two keys stored in the registry that I'd like to stop putting there.

Is there a way to do what I want without using the registry?

Not that it should matter but the code is .Net (one module is C# the other VB).


Solution

  • Just in case you don't realize, any roll-your own "copy protection" is not going to be very effective if your application becomes at all popular. You complicate life for legit. users in any case -- as well as your support issues. Copy protection is a bit of a misnomer, what you are really trying to accomplish is execute protection.

    In terms of "obscure locations", the registry is a popular choice for a good reason. It is a very crufty place, that most users are loathe to visit, if they are even aware of its existence.

    Check out the SpecialFolder enumeration constant for use with the Environment.GetFolderPath function

    The CommonApplicationData folder is not particularly well-known and it is at least a legit. area to store per-application data. This will resolve to different locations on disk depending upon your windows version.

    ADDED

    As I recall, no admin priv. is needed -- after all, it is an shared application data folder -- I've used it before without admin priv. but who knows what happens under Window 9, etc. Be sure to put it in a subfolder instead of the CommonApplicationData folder itself.

    BTW, the registry also requires elevated priv. to write in modern versions of Windows (for most key locations). Your installer program should run with elevated priv. but your application should not. Some of the other special folders may also need elevated priv., don't know anyplace this is conveniently documentated.