Per-machine configuration data should be stored in a sub-folder of the location referenced by FOLDERID_ProgramData
.
The location can change depending on what OS version you are using. It can also be localized (folder names that vary depending on the system language). It can also be changed by the system administrator.
Therefore, it’s very important that you do not hard-code the folder name into your app. Instead, you use the Known Folders APIs. Call SHGetKnownFolderPath
, passing one of the KNOWNFOLDERID
values.
This MSDN blog post explains which Known Folders to use in various scenarios.
PWSTR path = nullptr;
HRESULT hr = SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &path);
if (FAILED(hr)) {
// error handling
}
// use the path
// when you are done, you must free the memory yourself:
CoTaskMemFree(path);