From 5e47d3a9adb549eb001a041a95fac285b256aa99 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Mon, 9 Aug 2021 13:44:30 +0200 Subject: Added IsProcessRunning()/GetCurrentProcessId() helpers --- zencore/thread.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'zencore/thread.cpp') 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) { -- cgit v1.2.3