From 18835c324e78efe0fbbc49b68e430a601e474b35 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Tue, 16 Jan 2018 11:33:34 +0100 Subject: [PATCH] [util] Added getExeName() function This will allow DXVK to apply game-specific features or workarounds in the future. --- src/util/util_env.cpp | 16 ++++++++++++++++ src/util/util_env.h | 10 ++++++++++ 2 files changed, 26 insertions(+) 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