mirror of
https://github.com/Thracky/GlosSI.git
synced 2024-11-03 09:40:18 +00:00
cleanup
note to self: sleep more
This commit is contained in:
parent
0588c8c5a0
commit
ce4c137a48
Binary file not shown.
@ -192,7 +192,7 @@ void SteamTarget::launchApplication()
|
||||
const QString appName = QDir::toNativeSeparators(QString::fromStdString(launch_app_path_)).split('\\').last();
|
||||
connect(&launch_check_timer_, &QTimer::timeout, [appName]()
|
||||
{
|
||||
if (!IsProcessRunning(appName.toStdWString().c_str()))
|
||||
if (!process_alive::IsProcessRunning(appName.toStdWString().c_str()))
|
||||
SteamTarget::quit();
|
||||
});
|
||||
QTimer::singleShot(10000, this, [this]()
|
||||
@ -220,7 +220,7 @@ void SteamTarget::launchApplication()
|
||||
{
|
||||
connect(&launch_check_timer_, &QTimer::timeout, [pid]()
|
||||
{
|
||||
if (!IsProcessRunning(pid))
|
||||
if (!process_alive::IsProcessRunning(pid))
|
||||
SteamTarget::quit();
|
||||
});
|
||||
QTimer::singleShot(10000, this, [this]()
|
||||
|
@ -2,34 +2,37 @@
|
||||
#include <Windows.h>
|
||||
#include <tlhelp32.h>
|
||||
|
||||
//stolen from: https://stackoverflow.com/questions/1591342/c-how-to-determine-if-a-windows-process-is-running
|
||||
inline bool IsProcessRunning(const wchar_t *processName)
|
||||
namespace process_alive
|
||||
{
|
||||
bool exists = false;
|
||||
PROCESSENTRY32 entry;
|
||||
entry.dwSize = sizeof(PROCESSENTRY32);
|
||||
//stolen from: https://stackoverflow.com/questions/1591342/c-how-to-determine-if-a-windows-process-is-running
|
||||
inline bool IsProcessRunning(const wchar_t *processName)
|
||||
{
|
||||
bool exists = false;
|
||||
PROCESSENTRY32 entry;
|
||||
entry.dwSize = sizeof(PROCESSENTRY32);
|
||||
|
||||
const HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
|
||||
const HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
|
||||
|
||||
if (Process32First(snapshot, &entry))
|
||||
do {
|
||||
if (!_wcsicmp(entry.szExeFile, processName))
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
} while (Process32Next(snapshot, &entry));
|
||||
if (Process32First(snapshot, &entry))
|
||||
do {
|
||||
if (!_wcsicmp(entry.szExeFile, processName))
|
||||
{
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
} while (Process32Next(snapshot, &entry));
|
||||
|
||||
CloseHandle(snapshot);
|
||||
return exists;
|
||||
}
|
||||
CloseHandle(snapshot);
|
||||
return exists;
|
||||
}
|
||||
|
||||
inline BOOL IsProcessRunning(DWORD pid)
|
||||
{
|
||||
const HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
|
||||
if (process == nullptr)
|
||||
return false;
|
||||
const DWORD ret = WaitForSingleObject(process, 0);
|
||||
CloseHandle(process);
|
||||
return ret == WAIT_TIMEOUT;
|
||||
inline BOOL IsProcessRunning(DWORD pid)
|
||||
{
|
||||
const HANDLE process = OpenProcess(SYNCHRONIZE, FALSE, pid);
|
||||
if (process == nullptr)
|
||||
return false;
|
||||
const DWORD ret = WaitForSingleObject(process, 0);
|
||||
CloseHandle(process);
|
||||
return ret == WAIT_TIMEOUT;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user