Our application is used by millions of people. I found that about 0.1 ~ 0.3 % computers will miss the registry item, or set to be empty, so lead to lots of trouble shooting.
My suggestion is to use SHGetSpecialFolderPathA instead of get the folder from registry, in HKEY_LOCALMACHINE\SOFTWARE
Microsoft
Windows
CurrentVersion?
Explorer
Shell Folders.
The code is like this: inline void get_shared_documents_folder(std::string &s) {
s.clear(); char szPath[MAX_PATH]; if(SHGetSpecialFolderPathA(NULL,szPath,CSIDL_COMMON_APPDATA,FALSE)) {
s = szPath;
}
}