views:

172

answers:

2

I need to write some registration data (unique computer number, and corresponding activation code).

The Computer Number needs to be visible from other programs and all accounts ({Admin|Non Admin} with User Access Control turned {On|Off} )

It's acceptable to write the Computer Number and Activation Code only from an Admin account, but it needs to be readable from any of the other accounts.

Currently (and I need to test this more) it seems that if the the CN and Activation Code are written with UAC off then when the user switches UAC ON the Computer Number isn't visible.

+3  A: 

During install time you can write it to your program's install folder, since presumably it won't change (require write access) later. You should still have read access there as a standard user. Otherwise, how would run the program? :)

Or you can use the All Users Application Data folder. In XP, that would normally map to C:\Documents and Settings\All Users\Application Data\YourApp\. I don't have Vista in front of me, so I can't give you the exact location at the moment, but it should be a pretty simple mapping.

Joel Coehoorn
+3  A: 

The location returned by

Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)

This is the same location that Joel mentioned in his message, but this is the proper way of getting that value (which changed locations between XP & Vista and may change again).

(This is, of course, for .NET. For Win32, you want to use the SHGetFolderPath function with CSIDL_COMMON_APPDATA)

James Curran