diff options
| author | Stefan Boberg <[email protected]> | 2021-08-09 13:44:30 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2021-08-09 13:44:30 +0200 |
| commit | 5e47d3a9adb549eb001a041a95fac285b256aa99 (patch) | |
| tree | 05ba61cc5c1fba78af697c93253fb9e110a30cd8 | |
| parent | Added some new management commands (diff) | |
| download | zen-5e47d3a9adb549eb001a041a95fac285b256aa99.tar.xz zen-5e47d3a9adb549eb001a041a95fac285b256aa99.zip | |
Added IsProcessRunning()/GetCurrentProcessId() helpers
| -rw-r--r-- | zencore/include/zencore/thread.h | 1 | ||||
| -rw-r--r-- | zencore/thread.cpp | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h index 8a0adbe9f..4b5267a29 100644 --- a/zencore/include/zencore/thread.h +++ b/zencore/include/zencore/thread.h @@ -143,6 +143,7 @@ private: }; ZENCORE_API bool IsProcessRunning(int pid); +ZENCORE_API int GetCurrentProcessId(); ZENCORE_API void Sleep(int ms); diff --git a/zencore/thread.cpp b/zencore/thread.cpp index 5cbb6999d..eb16201fd 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -220,6 +220,27 @@ ProcessHandle::Wait(int TimeoutMs) return false; } +bool +IsProcessRunning(int pid) +{ + HANDLE hProc = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid); + + if (hProc == NULL) + { + return false; + } + + CloseHandle(hProc); + + return true; +} + +int +GetCurrentProcessId() +{ + return ::GetCurrentProcessId(); +} + void Sleep(int ms) { |