tags:

views:

295

answers:

4

Hi All,

I have a doubt in licensing. I am using C# application. Scenario: User gets the license for the application through mail in the form of file. He/She stores the license file on the Desktop. Later, he/she chooses the license and click register. Now the application is registered (Licensed). After some days, if user deletes the license file from Desktop. The application will stop working since there is no file. I want to store the license details somewhere in registry or file (secret path). But what if that user account doesn't have enough permission to read/write registry or file. Which is the good way? Do you guys know any other method? I am novice in this area. So please help me.

Thanks in advance.

+3  A: 

All application data should be stored in the %appdata% directory.

Since you specified C#, here's the code to get the folder:

Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

This will output to the following location: In XP: C:/Documents and Settings/username/Application Data/ In Vista: C:/Users/username/AppData/Roaming

I'd recommend you create a folder in that directory for your application and copy there.

Will Eddins
If you plan on having multiple users (on the same computer) use your software, you should put the license in the 'All Users' directory (on XP), so C:/Documents and Settings/All Users/Application Data/ .
Dashogun
ie Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
Martin Brown
A: 

As some one told me some time ago : "The registry is for interaction of the application with the system, not for the interaction of the application with the user." I don't know if this is the right way to see things. I used to store user information in the registry too but not anymore. Putting settings in a file is the better way. If you want to store things like serial numbers don't forget to crypt them.

Holli
A: 

Absolutely, writing to the registry should probably be avoided in this case, especially if the license can be deleted, added, or altered in the way you seem to be describing. If the licenses is meant to be swapped out or changed in some way after installation, it may be better to write it to a file. Though, I usually don't recommend writing any sort of critical file or data like that to the desktop. I would probably write it to a folder contained within a directory of the application itself. Include it in your application installation if it is that necessary.

Zensar
The license is already a file I believe, based on the original question. Also, writing in the application installation directory is typically not a good idea. You do not have write access to it in Vista/7 due to UAC, since applications should only be writing to the user's appdata directories.
Will Eddins
+2  A: 

Microsoft has some suggestions for storage locations in the Windows Vista: Application Certification and Compatibility document.

So, if it [your program] is ever changing shared DATA (not CODE) then it [the data] should logically go in to ProgramData folder. If it is individual DATA then it can go to the user profile.

We use a license file and store it in the ProgramData\CompanyName folder. But our licenses are on a per machine basis, not a per user. By default, this folder is hidden in Windows, but is not protected by UAC.

bsruth
Exactly! And as mentioned above, is accessible in C# by: Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
Jared Harley