ifzah
asked on
How to check programatically , either a program is running or not.
Like in Task Manager, we can see a program runnnning or not, is there any way that we can check programaticallly , either the program is running or not.
Can we check from registry etc or from task manager.
Please tell me how.
i would be grateful
ifzah
Can we check from registry etc or from task manager.
Please tell me how.
i would be grateful
ifzah
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can get a list of process names, but if a process doesnt want to be found, there are lots of ways it can hide.
Try this.
HMODULE hModules[10];
TCHAR szFileName[MAX_PATH];
HANDLE process = OpenProcess(PROCESS_QUERY_ INFORMATIO N | PROCESS_VM_READ, FALSE, nProcessID);
EnumProcessModules(process , hModules, sizeof(hModules), &nModuleNo);
DWORD nModuleNo /= sizeof(hModules[0]);
if ( GetModuleFileNameEx(proces s, hModules[0], szFileName, sizeof(szFileName)) )
{
// EXE name will be got in szFileName
}
HMODULE hModules[10];
TCHAR szFileName[MAX_PATH];
HANDLE process = OpenProcess(PROCESS_QUERY_
EnumProcessModules(process
DWORD nModuleNo /= sizeof(hModules[0]);
if ( GetModuleFileNameEx(proces
{
// EXE name will be got in szFileName
}
> // EXE name will be got in szFileName
Note that IIRC there's nothing secure in the exe file name, it's not checksummed or MD5'ed or digitally signed or anything, so any program or spyware or virus or worm is free to change the name to anything at any instant.
You might have better luck checking the executable's current data segment for strings it HAS to have in it, like "/bin/sh" or in Windows some likely path or file name it works with.
Or even better, if you're looking for some nasty program, look in its code for calls or loaded images of the core system DLL's.
Note that IIRC there's nothing secure in the exe file name, it's not checksummed or MD5'ed or digitally signed or anything, so any program or spyware or virus or worm is free to change the name to anything at any instant.
You might have better luck checking the executable's current data segment for strings it HAS to have in it, like "/bin/sh" or in Windows some likely path or file name it works with.
Or even better, if you're looking for some nasty program, look in its code for calls or loaded images of the core system DLL's.
>> Like in Task Manager
See http://support.microsoft.com/kb/175030/en-us ("How To Enumerate Applications Using Win32 APIs")
See http://support.microsoft.com/kb/175030/en-us ("How To Enumerate Applications Using Win32 APIs")
Regards, Alex