开发者

Is there any reliable API to Get Windows Folder in Windows?

开发者 https://www.devze.com 2023-01-05 13:30 出处:网络
Is there any reliable API to Get Windows Folder in Windows in C++? I am using the following way, however it failed.

Is there any reliable API to Get Windows Folder in Windows in C++? I am using the following way, however it failed.

开发者_JS百科    BOOL CQUserInfoHelper::GetWindowsPath(CString& strWindowsPath)
    {
        TCHAR windowsPathTemp[MAX_PATH];
        int nSize = MAX_PATH;
        ::GetWindowsDirectory(
            windowsPathTemp,
            nSize);
        strWindowsPath = windowsPathTemp;
        return TRUE;
    }


Try This -

const DWORD dwBufferLength = 65537;
CStringW strBuffer;

if (!::GetCurrentDirectory(   dwBufferLength , 
                              strBuffer.GetBuffer(dwBufferLength))    ) 
   return L"";

...

strBuffer.ReleaseBuffer();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号