Where to store program settings instead of HKEY_LOCAL_MACHINE?

后端 未结 10 1825
星月不相逢
星月不相逢 2020-12-05 01:19

I have some program settings that are currently stored in HKEY_LOCAL_MACHINE. Due to Vista and locked down users, some users don\'t have permission to HKEY_LOCAL_MACHINE, an

10条回答
  •  误落风尘
    2020-12-05 01:58

    You should put:

    • personal settings (like window position and minor preferences) under HKEY_CURRENT_USER in the registry or in the CSIDL_APPDATA or CSIDL_LOCAL_APPDATA folder;
    • important application settings (like a fixed path that should not be modified by your users) under HKEY_LOCAL_MACHINE in the registry or in the application's folder. Set them at install time, when administrator privileges are available;
    • shared data (data that all of your users should read and write to, like a simple database) in the CSIDL_COMMON_APPDATA folder.

    Use SHGetFolderPath to find the location of the CSIDL_* folders.

    Depending on your needs you might like to implement all three options given at once. There would be nothing wrong with it.

提交回复
热议问题