|
#include "StdAfx.h"
#include "SysUtil.h"
CSysUtil CSysUtil::g_SysUtil;
CSysUtil::CSysUtil(void)
{
s_SystemFolder.resize(64);
::GetEnvironmentVariable(_T("SYSTEMROOT"), (LPTSTR)s_SystemFolder.c_str(), 64);
shrink(s_SystemFolder);
}
void CSysUtil::FixSysPath(tstring & path)
{
tstring s = path;
size_t srcLength = s.size();
make_upper(s);
tstring sys = _T("\\SYSTEMROOT");
size_t L = sys.size();
if(!s.find(sys.c_str(), 0, L))
{
tstring tmp = g_SysUtil.s_SystemFolder;
tmp.append(path.c_str(), L, srcLength - L);
path = tmp.c_str();
return;
}
sys = _T("\\??\\");
L = sys.size();
if(!s.find(sys.c_str(), 0, L))
{
tstring tmp;
tmp.append(path.c_str(), L, srcLength - L);
path = tmp.c_str();
return;
}
sys = _T("SYSWOW64");
bool bAppend = (s.find(sys.c_str(), 0, sys.size()) == 0);
if(!bAppend)
{
sys = _T("SYSTEM32");
bAppend = (s.find(sys.c_str(), 0, sys.size()) == 0);
}
if(bAppend)
{
tstring tmp = g_SysUtil.s_SystemFolder;
tmp.append(_T("\\"));
tmp.append(path.c_str());
path = tmp;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.