Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Apr : OpenProcess Access Denied

www.cryer.info
Managed Newsgroup Archive

OpenProcess Access Denied

Subject:OpenProcess Access Denied
Posted by:"Marcelo Grossi" (no@spam.com)
Date:11 Apr 2008 03:49:49 -0700

Hello,
I'm trying to use OpenProcess to monitor the performance of a process (memory and cpu usage). I'm running an application as the administrator of the machine (Win XP PRO) and I get the ErrorCode = 5 (Access Denied) when trying to use the OpenProcess on a VALID ProcessID, obtained as follows:

ProcessWnd  := FindWindow(ProcClassPt, ProcNamePt);
GetWindowThreadProcessId(ProcessWnd, ProcessPID);
ProcessPHnd := OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessPID);

The first two lines execute OK. I get the correct Wnd and Pid but it fails on the third line (OpenProcess). I know that this process that I'm trying to monitor has been created by a Service that also has administrator rights.

Any ideas on how not go get my access denied on that particular process?

Thank you

Glossary

Replies:

www.cryer.info
Managed Newsgroup Archive