GetPriorityClass in Win2003

Y

Yaniv M

Hi,

My goal is to verify that a process is alive, therefore I use the
GetPriorityClass function, if this API function succeed it means that the
searched process is alife, otherwise it died.
The problem is that in Windows 2003 this function returns success even if
the process is dead.
Why it happens in Win2003? What is the way to solve this problem? Is there
any other way to check if the process alive?

Thanks,
Yaniv M

DWORD GetPriorityClass(
HANDLE hProcess // handle to process
);

code example:

HANDLE hProc;

//this line was add to support work with windows 2000.
hProc = OpenProcess(PROCESS_QUERY_INFORMATION , FALSE ,
process_info.dwProcessId);
// we can check if(hProc != NULL)
if((GetPriorityClass(hProc) == 0 ) && (app_type != WOW_16_BIT_APP ))
{
sprintf(logstr,"Process %s %s died",exefile, name==NULL?"":name);
}
else
{
// the process is alive.
}
 
J

Jon Skeet [C# MVP]

Yaniv M said:
My goal is to verify that a process is alive, therefore I use the
GetPriorityClass function, if this API function succeed it means that the
searched process is alife, otherwise it died.
The problem is that in Windows 2003 this function returns success even if
the process is dead.
Why it happens in Win2003? What is the way to solve this problem? Is there
any other way to check if the process alive?

Process.HasExited?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top