diff --git a/src/util/util_env.cpp b/src/util/util_env.cpp index 8998b43f..0464bc38 100644 --- a/src/util/util_env.cpp +++ b/src/util/util_env.cpp @@ -19,4 +19,20 @@ namespace dxvk::env { 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; + } + } diff --git a/src/util/util_env.h b/src/util/util_env.h index ad9cdf52..3d5cf230 100644 --- a/src/util/util_env.h +++ b/src/util/util_env.h @@ -15,4 +15,14 @@ namespace dxvk::env { */ std::string getEnvVar(const wchar_t* name); + /** + * \brief Gets the executable name + * + * Returns the base name (not the full path) of the + * program executable, including the file extension. + * This function should be used to identify programs. + * \returns Executable name + */ + std::string getExeName(); + } \ No newline at end of file