Saving global data as a standard user?

in my application, I need to save settings that are “global” (that is, not user-defined) in a known and predictable location.

I want the application to be launched from anywhere (as a standard user, NOT an administrator), including several copies from different places and the ability to read and write saved configuration files.

Data should have read and write access, provided to ALL standard users, and not just one.

With this in mind, the four options noted here are inappropriate: http://msdn.microsoft.com/en-us/library/bb206295(VS.85).aspx#ID0E1BA

So what are my alternatives?

My application is written in C ++ and only for Windows. I need to support Windows XP and above.

Thanks.

EDIT:

To clarify, ignore race conditions caused by multiple instances. This question is related exclusively to WHERE TO BUY DATA. I do not see anywhere suitable:

  • Predictable (for example,% APPDATA% \ Foo is a "predictable" path, but unfortunately for the user)
  • Global (for example,% PROGRAMDATA% \ Foo is a global path, but, unfortunately, only the creating user has write access)
  • Accessible (a standard user should be able to create new files in this directory, this applies to all users in the system)
+5
source share
5 answers

, CSIDL_COMMON_APPDATA (, CSIDL_COMMON_APPDATA , , ), - HKLM\SOFTWARE\<your app subkey>, , .

HKLM , , . , ( ) . , ( HKLM, ), , .

, ( ), , ACL .

+2

:

CSIDL_COMMON_DOCUMENTS

:

CSIDL_COMMON_APPDATA

, , " ".

+1

, CSIDL_COMMON_APPDATA. IIRC, , Windows. , MSDN, .
.

+1

, . C:\FixedDataForYourProgram

We do this on XP. I did not try this programmatically in Vista / Win7, but logged in as a regular user in Vista. I have no problem creating a directory as root.

I am sure that this violates all kinds of rules, but it is simple. I like it simply.

+1
source

options:

  • File Mutex to control file access
  • Database for saving settings
  • A web service for storing settings that can handle concurrency
-2
source

All Articles