1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-14 09:23:53 +01:00
dxvk/src/util/util_env.cpp

39 lines
826 B
C++
Raw Normal View History

2017-12-08 11:18:23 +01:00
#include "util_env.h"
#include "./com/com_include.h"
namespace dxvk::env {
std::string getEnvVar(const wchar_t* name) {
DWORD len = ::GetEnvironmentVariableW(name, nullptr, 0);
std::wstring result;
while (len > result.size()) {
result.resize(len);
len = ::GetEnvironmentVariableW(
name, &result.at(0), result.size());
2017-12-08 11:18:23 +01:00
}
result.resize(len);
return str::fromws(result);
}
std::string getExeName() {
std::wstring exePath;
exePath.resize(MAX_PATH + 1);
DWORD len = ::GetModuleFileNameW(NULL, &exePath.at(0), MAX_PATH);
exePath.resize(len);
std::string fullPath = str::fromws(exePath);
auto n = fullPath.find_last_of('\\');
return (n != std::string::npos)
? fullPath.substr(n + 1)
: fullPath;
}
2017-12-08 11:18:23 +01:00
}