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
TomazazAsked:
Who is Participating?
 
ziolkoCommented:
try to lower your access to PROCESS_QUERY_INFORMATION

ziolko.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.