在哪里存储配置数据以供管理员和非管理员通用访问?

发布于 2024-12-12 02:41:26 字数 541 浏览 0 评论 0原文

我可以告诉您非管理员不允许写入的位置:

Environment::GetFolderPath(Environment::SpecialFolder::ApplicationData) + "\\Config.ini";
Environment::GetFolderPath(Environment::SpecialFolder::CommonApplicationData) + "\\monitorService\\Config.ini";
Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\monitorService\\Config.ini";

我对 Environment::SpecialFolder::CommonApplicationData 寄予厚望,但遗憾的是普通有限用户也无法写入。我需要一个通用的、易于犯错、了解和掌握的方法。找到我可以从中加载配置数据并将其保存到的目录。我想我可以支持每个用户的配置文件,但我宁愿让事情尽可能简单。

我是否可以让我的安装程序留出

I can tell you where non-admin's aren't allowed to write to:

Environment::GetFolderPath(Environment::SpecialFolder::ApplicationData) + "\\Config.ini";
Environment::GetFolderPath(Environment::SpecialFolder::CommonApplicationData) + "\\monitorService\\Config.ini";
Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\monitorService\\Config.ini";

I had high hopes for Environment::SpecialFolder::CommonApplicationData but sadly that one's off limits for ordinary limited users also. I need a common, easy to, err, know & find, directory where I can load configuration data from and save it to. I suppose I could countenance per-user config files, but I'd rather keep things as simple as possible.

Could I perhaps have my installer set aside some area of the registry or filesystem for universal access? I use Innosetup and .NET code to install. I've noticed (IRC) firefox fills up "Application Data" folders for named and default users so I guess that's another possibility. As the config data is needed by the service it might be too much trouble to store a couple of short strings and ints in anything other than the registry.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

单身狗的梦 2024-12-19 02:41:26

由于没有人回答,我不妨在实施时提出我的解决方案。

有限用户仅对 HKCU 具有写权限。这与使用文件系统相同 - 一些用户特定的分支将是可写的。必须在用户登录的正确时间检查对全局配置文件的写访问权限,然后在抛出异常时委托给用户本地配置,这很麻烦,但这是必须要做的。为了更容易进行碎片整理并且对性能影响较小,我会在 HKCU 之前尝试使用 FS。

Since no one has answered I may as well posit my solution while I go about the implementation.

Limited users only have write access to HKCU. This is the same as using the file system- some user specific branches will be writable. It is hassle to have to check for write access to the global config file at the right time the user logs on and then delegate to user-local config if it throws, but that is what must be done. Being easier to defrag and less of a performance hit I will attempt using the FS before HKCU.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文