diff options
| author | Stefan Boberg <[email protected]> | 2021-09-17 23:16:34 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-09-17 23:16:34 +0200 |
| commit | 91c305d98ab2a0482114c2d52d23ef787f08190d (patch) | |
| tree | b2a33fc86532424b1efa3fb28a48796e4aa76b78 | |
| parent | IsProcessRunning now throws if it fails the function fails to get a handle to... (diff) | |
| download | zen-91c305d98ab2a0482114c2d52d23ef787f08190d.tar.xz zen-91c305d98ab2a0482114c2d52d23ef787f08190d.zip | |
Added IsInteractiveSession() query to help identify if the process is running as a daemon or as an interactive process
| -rw-r--r-- | zencore/include/zencore/zencore.h | 2 | ||||
| -rw-r--r-- | zencore/zencore.cpp | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h index 4f9dc6322..310f6c4ed 100644 --- a/zencore/include/zencore/zencore.h +++ b/zencore/include/zencore/zencore.h @@ -188,6 +188,8 @@ ZENCORE_API bool IsPointerToStack(const void* ptr); // Query if pointer is with ZENCORE_API bool IsApplicationExitRequested(); ZENCORE_API void RequestApplicationExit(int ExitCode); ZENCORE_API bool IsDebuggerPresent(); +ZENCORE_API bool IsInteractiveSession(); + ZENCORE_API void zencore_forcelinktests(); } // namespace zen diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp index d0b1135dc..122719d90 100644 --- a/zencore/zencore.cpp +++ b/zencore/zencore.cpp @@ -67,6 +67,23 @@ IsDebuggerPresent() #endif } +bool +IsInteractiveSession() +{ +#if ZEN_PLATFORM_WINDOWS + DWORD dwSessionId = 0; + if (ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionId)) + { + return (dwSessionId != 0); + } + + return false; +#else + // TODO: figure out what makes sense here + return true; +#endif +} + ////////////////////////////////////////////////////////////////////////// static int s_ApplicationExitCode = 0; |