Get path to My Documents

后端 未结 5 1802
忘了有多久
忘了有多久 2020-12-06 05:18

From Visual C++, how do I get the path to the current user\'s My Documents folder?

Edit:

I have this:

TCHAR my_documents[MAX         


        
5条回答
  •  春和景丽
    2020-12-06 05:50

    std::string GetSystemFolderPaths(int csidl)
    {
        wchar_t Folder[1024];
        HRESULT hr = SHGetFolderPathW(0, CSIDL_MYDOCUMENTS, 0, 0, Folder);
        if (SUCCEEDED(hr))
        {
            char str[1024];
            wcstombs(str, Folder, 1023);
            return str;
        }
        else return "";
    }
    
    cout<

    how about this solution? Its working fine for me.

提交回复
热议问题