Hi madshi,
is there a way to detect if an appliction is suspended (sth. like process('app.exe').IsSuspend)?
Is it dangerous to use process('app.exe').RESUME in a timer to make sure another app doesn't suspend my one?
thanks in advance!
IProcess.IsSuspend
Re: IProcess.IsSuspend
Not in one call. But you can loop through the threads and call "IThread.IsSuspended" for each of the threads. Please don't ask "IsSuspended" on yourself, though! Cause that would suspend yourself. So you should do something like this:djsale wrote:is there a way to detect if an appliction is suspended (sth. like process('app.exe').IsSuspend)?
Code: Select all
function IsProcessSuspended(process: IProcess) : boolean;
var i1 : integer;
begin
result := true;
with process.Threads do
for i1 := 0 to ItemCount - 1 do
if (Items[i1].ID <> GetCurrentThreadId) and (not Items[i1].IsSuspended) then begin
result := false;
break;
end;
end;
It's not that dangerous, if you don't ever suspend any of your own threads - and if there aren't any 3rd party components in your process which are creating their own threads and suspending them. However, calling Myself.Resume in a timer won't help much, cause the timer event will not fire, anymore, if your process actually gets suspended!djsale wrote:Is it dangerous to use process('app.exe').RESUME in a timer to make sure another app doesn't suspend my one?
Re: IProcess.IsSuspend
Thanks a lot for this great and explicitely explanation. The best way ever would be to disallow suspending via hooking (like disabling process terminate). But I don't have any idea how to do that at all...
Any hint would be highly appreciated!
Any hint would be highly appreciated!