Hi Kanu,
perhaps this code-snippet will help you ...
regards
Peter
#include <tlhelp32.h>
/// HIFN Get a list of all running processes to check if XXX is running on same system
/// HIPAR szExecutableToCheckIfRunning/char, Name of executable to look for
/// HIRET = 1 found executable to look for
/// HIRET = 0 did not found executable
/// HIRET < 0 error
int GetProcessList(char * szExecutableToCheckIfRunning)
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;
int bFound=FALSE;
// Take a snapshot of all processes in the system.
hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 );
if( hProcessSnap == INVALID_HANDLE_VALUE )
{
printf( "CreateToolhelp32Snapshot (of processes)" );
return -1;
}
// Set the size of the structure before using it.
pe32.dwSize = sizeof( PROCESSENTRY32 );
// Retrieve information about the first process,
// and exit if unsuccessful
if( !Process32First( hProcessSnap, &pe32 ) )
{
printf( "Process32First") ; // show cause of failure
CloseHandle( hProcessSnap ); // clean the snapshot object
return -1;
}
// Now walk the snapshot of processes, and
// display information about each process in turn
do
{
if (stricmp(pe32.szExeFile, szExecutableToCheckIfRunning)==0)
bFound=TRUE;
} while( Process32Next( hProcessSnap, &pe32 ) );
CloseHandle( hProcessSnap );
return bFound;
}