Skip to content

Instantly share code, notes, and snippets.

@lyf-is-coding
Created August 20, 2022 07:03
Show Gist options
  • Save lyf-is-coding/b421dc26f70330d22a81027c8449559c to your computer and use it in GitHub Desktop.
Save lyf-is-coding/b421dc26f70330d22a81027c8449559c to your computer and use it in GitHub Desktop.
C++ Get Documents directory path using Window Shell
#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