Skip to content
Snippets Groups Projects
Commit 197cf2d7 authored by aacuevas's avatar aacuevas
Browse files

Fixed windows implementation of getEnvironmentVariable

parent 14e0c607
Branches
Tags
No related merge requests found
......@@ -359,17 +359,15 @@ const String SystemStats::getFullUserName()
String SystemStats::getEnvironmentVariable (const String& name, const String& defaultValue)
{
DWORD len = GetEnvironmentVariableW (name.toWideCharPointer(), 0, 0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
DWORD len = GetEnvironmentVariable(name,0,0);
if (GetLastError() == ERROR_ENVVAR_NOT_FOUND)
return String (defaultValue);
HeapBlock<WCHAR> buffer (len);
len = GetEnvironmentVariableW (name.toWideCharPointer(), buffer, len);
return String (CharPointer_wchar_t (buffer),
CharPointer_wchar_t (buffer + len));
}
HeapBlock<WCHAR> buffer (len);
len = GetEnvironmentVariable (name, buffer, len);
return String (buffer,len);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment