aboutsummaryrefslogtreecommitdiff
path: root/zencore
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-08-06 15:01:43 +0200
committerStefan Boberg <[email protected]>2021-08-06 15:01:43 +0200
commit199b99477838a321345d51e8ac886bf82e1d20cc (patch)
treeaba17a5601d83b0e5b6ed076c16c82c93d1c055b /zencore
parentAdded single instance (per port) logic to ZenServer class (diff)
downloadzen-199b99477838a321345d51e8ac886bf82e1d20cc.tar.xz
zen-199b99477838a321345d51e8ac886bf82e1d20cc.zip
Added GetRunningExecutablePath()
Diffstat (limited to 'zencore')
-rw-r--r--zencore/filesystem.cpp9
-rw-r--r--zencore/include/zencore/filesystem.h2
2 files changed, 11 insertions, 0 deletions
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index c4c4a6ff0..7b123eb4e 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -610,4 +610,13 @@ PathFromHandle(void* NativeHandle)
return FullPath;
}
+std::filesystem::path
+GetRunningExecutablePath()
+{
+ TCHAR ExePath[MAX_PATH];
+ DWORD PathLength = GetModuleFileName(NULL, ExePath, ZEN_ARRAY_COUNT(ExePath));
+
+ return {std::wstring_view(ExePath, PathLength)};
+}
+
} // namespace zen
diff --git a/zencore/include/zencore/filesystem.h b/zencore/include/zencore/filesystem.h
index ba8588c5c..d8140932b 100644
--- a/zencore/include/zencore/filesystem.h
+++ b/zencore/include/zencore/filesystem.h
@@ -33,6 +33,8 @@ ZENCORE_API bool CleanDirectory(const std::filesystem::path& dir);
*/
ZENCORE_API std::filesystem::path PathFromHandle(void* NativeHandle);
+ZENCORE_API std::filesystem::path GetRunningExecutablePath();
+
struct FileContents
{
std::vector<IoBuffer> Data;