Share read/write application data (on disk) between users on Windows
I'm porting a game to Windows and wonder how, for example, highscore data should be stored so that all users on the same sy开发者_开发百科stem can share the data. Ideally the data shouldn't be writeable by the users themselfs, only by the application (in this case game) owning the data. Apart from the pure technical details I also wonder about best practise.
On Unix this can be achieved by setting the set-UID bit on the executable and let the executable and the shared file in question belong to the same system-user (games in my case). There is also a best practise to place such files in /var/lib/games.
First, what you can't do:
- You can't let some executable change some value, but prevent the user running it from doing so.
- You can't make some executable run under a specific account, unless you use some sort of loader (another executable) that will ensure that.
- You can't use the registry to store shared data, unless your users are running as administrators (which should not be an option).
Now, what you can do:
- Use a database...
- Use the ProgramData folder ("All Users" on XP).
- Use some loader to keep your app running under the same user, which opens both that user's registry and AppData folder (bad idea - just mentioning as it is technically possible).
If #1 is not possible, I'd go for #2.
A good read about this topic: Where Should I Store my Data and Configuration Files if I Target Multiple OS Versions?
精彩评论