LookingGlass/host/Util.h

41 lines
766 B
C
Raw Normal View History

2017-10-31 13:51:53 +00:00
#pragma once
#include <string>
#include "common\debug.h"
2017-10-31 14:46:47 +00:00
class Util
2017-10-31 13:51:53 +00:00
{
public:
static std::string GetSystemRoot()
{
std::string defaultPath;
size_t pathSize;
char *libPath;
if (_dupenv_s(&libPath, &pathSize, "SystemRoot") != 0)
{
DEBUG_ERROR("Unable to get the SystemRoot environment variable");
return defaultPath;
}
if (!pathSize)
{
DEBUG_ERROR("The SystemRoot environment variable is not set");
return defaultPath;
}
#ifdef _WIN64
defaultPath = std::string(libPath) + "\\System32";
#else
if (IsWow64())
{
defaultPath = std::string(libPath) + "\\Syswow64";
}
else
{
defaultPath = std::string(libPath) + "\\System32";
}
#endif
return defaultPath;
}
};