Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whether an application is running?

Status
Not open for further replies.

chaitu

Programmer
May 30, 2002
17
MO
I am writing a service and my service is supposed to function only when a particular application is not running.

But, How do I determine whether that particular exe - for which I know the exact name - is running or not?

Is there a way to programatically achieve this?

Regards & thanks in advance,
Chaitu
 
I myself found the answer,
Thanks,

I am attaching the code for it might be useful...

<Code>
#include &quot;tlhelp32.h&quot;

BOOL bRet;
PROCESSENTRY32 eProcess;

HANDLE hProcessEnumerator = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

bRet = Process32First(hProcessEnumerator, &eProcess);

do
{
/* Do what you want, by accessing eProcess*/
bRet = Process32Next(hProcessEnumerator, &eProcess);
}while(bRet);

</Code>
 
This will only work under 95/98, but not NT/2000 . See &quot;HOWTO: Enumerate Applications in Win32&quot; in MSDN.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top