Added suspend_process() function.

This commit is contained in:
LoRd_MuldeR 2015-02-08 22:22:23 +01:00
parent 02be92208f
commit b79936a0e6
2 changed files with 28 additions and 2 deletions

View File

@ -154,7 +154,10 @@ namespace MUtils
MUTILS_API bool change_process_priority(const QProcess *proc, const int priority); MUTILS_API bool change_process_priority(const QProcess *proc, const int priority);
//Process ID //Process ID
MUTILS_API quint32 process_id(const QProcess *proc); MUTILS_API quint32 process_id(const QProcess *const proc);
//Suspend or resume processv
MUTILS_API bool suspend_process(const QProcess *proc, const bool suspend);
//System timer resolution //System timer resolution
MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1); MUTILS_API bool setup_timer_resolution(const quint32 &interval = 1);

View File

@ -994,12 +994,35 @@ bool MUtils::OS::change_process_priority(const QProcess *proc, const int priorit
// PROCESS ID // PROCESS ID
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
quint32 MUtils::OS::process_id(const QProcess *proc) quint32 MUtils::OS::process_id(const QProcess *const proc)
{ {
PROCESS_INFORMATION *procInf = proc->pid(); PROCESS_INFORMATION *procInf = proc->pid();
return (procInf) ? procInf->dwProcessId : NULL; return (procInf) ? procInf->dwProcessId : NULL;
} }
///////////////////////////////////////////////////////////////////////////////
// PROCESS SUSPEND/RESUME
///////////////////////////////////////////////////////////////////////////////
bool MUtils::OS::suspend_process(const QProcess *proc, const bool suspend)
{
if(Q_PID pid = proc->pid())
{
if(suspend)
{
return (SuspendThread(pid->hThread) != ((DWORD) -1));
}
else
{
return (ResumeThread(pid->hThread) != ((DWORD) -1));
}
}
else
{
return false;
}
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// SYSTEM TIMER // SYSTEM TIMER
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////