work around GetEnvironmentVariable not resetting last error
This commit is contained in:
parent
fd035084de
commit
597061aed1
|
@ -29,6 +29,7 @@ std::wstring GetEnv(const wchar_t *const variable_name)
|
||||||
if (not bufsize)
|
if (not bufsize)
|
||||||
throw win32_error{};
|
throw win32_error{};
|
||||||
std::wstring buf(bufsize, noncharacter);
|
std::wstring buf(bufsize, noncharacter);
|
||||||
|
::SetLastError(0);
|
||||||
const auto res =
|
const auto res =
|
||||||
::GetEnvironmentVariableW(variable_name, buf.data(), bufsize);
|
::GetEnvironmentVariableW(variable_name, buf.data(), bufsize);
|
||||||
if (const auto e = ::GetLastError())
|
if (const auto e = ::GetLastError())
|
||||||
|
|
Loading…
Reference in a new issue