Is there any reliable API to Get Windows Folder in Windows?
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();
精彩评论