Created
August 20, 2022 07:03
-
-
Save lyf-is-coding/b421dc26f70330d22a81027c8449559c to your computer and use it in GitHub Desktop.
C++ Get Documents directory path using Window Shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <shlobj.h> | |
PWSTR documentsDirPath{}; | |
if (HRESULT ret = SHGetKnownFolderPath(FOLDERID_Documents, KF_FLAG_DEFAULT, 0, &documentsDirPath); ret == S_OK) | |
{ | |
std::wcout << L"Documents directory path: " << documentsDirPath << '\n'; | |
} | |
else | |
{ | |
std::wcout << L"[SHGetKnownFolderPath] " << ret << '\n'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment