Link to home
Start Free TrialLog in
Avatar of Tomazaz
Tomazaz

asked on

Somethign wrong with Openprocess

Hello,

I use function below to determinate is process is running or it is already terminated. While passing process ID as parameter it works perfect on WindowsXP, unfortunately it does not work on processes which was run by SYSTEM on Windows 2003. Function always return FALSE
through process is running.

function ProcessExists(PID: Cardinal): Boolean;
var
  x: THandle;
begin
  result := false;
  x := Openprocess(PROCESS_ALL_ACCESS, false, PID);
  if x <> 0 then
  begin
    result := true;
    CloseHandle(x);
  end;
end;

Regards,
Tomas
ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial