A few options:
Qt already has paths to many of these (cross-platform) in QDesktopServices. The method is QDesktopServices::storageLocation(StandardLocation)
.
For some, you can use qgetenv (as mentioned above).
If all else fails, you can directly call the SHGetSpecialFolderPath method in the Shell32 library. The list of possible options can be found on Microsoft's site.
Here is a sample of the last:
static QString getWindowsPath(int path_to_get)
{
typedef BOOL (WINAPI*GetSpecialFolderPath)(HWND, LPWSTR, int, BOOL);
QLibrary shell32_lib(QLatin1String("shell32"));
GetSpecialFolderPath SHGetSpecialFolderPath =
(GetSpecialFolderPath)shell32_lib.resolve("SHGetSpecialFolderPathW");
QScopedPointer<wchar_t> w_path(new wchar_t[MAX_PATH]);
SHGetSpecialFolderPath(0, w_path.data(), path_to_get, FALSE);
return QString::fromWCharArray(w_path.data());
}
(Actually, SHGetSpecialFolderPath
has been superseded by SHGetKnownFolderPath as of Vista, so if you know you are only targeting Windows 7, you should use that instead. It uses a KNOWNFOLDERID value.)