SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL, 0, szPath)
Error 1 error C2065: 'CSIDL_COMMON_APPDATA' : undeclared identifier
Error 2 error C3861: 'SHGetFolderPath': identifier not found
The alternative is described in the documentation to which you link. Namely it is
SHGetKnownFolderPath is only available on Vista or later. So if you use load time linking, and run a program that calls
SHGetKnownFolderPath on XP, then that program will fail to start. This is clearly a problem if you wish to support XP.
Now, you could switch to run time linking of
SHGetKnownFolderPath. Carry out a version check before you call it, and if the function is not available, then fall back to
Personally, I would not let this deprecation worry you excessively. Microsoft are renowned for maintaining backwards compatibility. Don't expect
SHGetFolderPath to disappear any time soon. You will find that
SHGetFolderPath exists in Windows 8 and I would expect it still to be present in whatever Windows is current 10 years from now. My advice is to stick to load time linking, and only switch to
SHGetKnownFolderPath when you give up supporting XP.
Your other question, that you ask in an edit, is how to call
SHGetFolderPath. You need to respect the requirements which are laid out at the bottom of the MSDN documentation topic which you linked to in your question. Specifically, include
Shlobj.h and pass
Shlobj.lib to the linker.