| 1 |
/* |
| 2 |
* Copyright (C) 2005-2020 Team Kodi (https://kodi.tv) |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 5 |
* See LICENSE.md for more information. |
| 6 |
*/ |
| 7 |
|
| 8 |
#include "WindowsUtils.h" |
| 9 |
#include <windows.h> |
| 10 |
#include <stdio.h> |
| 11 |
#include <string> |
| 12 |
|
| 13 |
namespace OS |
| 14 |
{ |
| 15 |
bool GetEnvironmentVariable(const char* strVarName, std::string& strResult) |
| 16 |
{ |
| 17 |
#ifdef TARGET_WINDOWS_DESKTOP |
| 18 |
char strBuffer[4096]; |
| 19 |
DWORD dwRet; |
| 20 |
|
| 21 |
dwRet = ::GetEnvironmentVariableA(strVarName, strBuffer, 4096); |
| 22 |
|
| 23 |
if(0 == dwRet) |
| 24 |
{ |
| 25 |
dwRet = GetLastError(); |
| 26 |
if( ERROR_ENVVAR_NOT_FOUND == dwRet ) |
| 27 |
{ |
| 28 |
strResult.clear(); |
| 29 |
return false; |
| 30 |
} |
| 31 |
} |
| 32 |
strResult = strBuffer; |
| 33 |
return true; |
| 34 |
#else |
| 35 |
return false; |
| 36 |
#endif // TARGET_WINDOWS_DESKTOP |
| 37 |
} |
| 38 |
} |