开发者

Share read/write application data (on disk) between users on Windows

开发者 https://www.devze.com 2023-04-11 12:27 出处:网络
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 write

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:

  1. You can't let some executable change some value, but prevent the user running it from doing so.
  2. You can't make some executable run under a specific account, unless you use some sort of loader (another executable) that will ensure that.
  3. 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:

  1. Use a database...
  2. Use the ProgramData folder ("All Users" on XP).
  3. 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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号