Application is running / not running / hang up

How can i find out if an application is running or not
i know only then exe-name (e.g. prg.exe)
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lukasz LachCommented:
check out the units
when you got the handle simply

if SendMessageTimeout(WHandle, WM_NULL, 0, 0, SMTO_ABORTIFHUNG, 5000, dw1) = 0 then
ShowMessage('Not responding');

use windows API
if FindWindow('classname', nil) <> 0 then }return window handle
classname in delphi are your main form name or you can use other tool like spy++(visual studio) to get the classname.

FindWindow(0, 'application title name')
Lukasz LachCommented:
but he knows exe file name only, FindWindow won't help...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

kostamaniaAuthor Commented:
in enumstuff is no procedure / function do find the handle of the exe-file
i'm looking for a func. like this

function ExeHandle(prog.exe):Handle

Lukasz LachCommented:
there is an enum function allowing to get the handle by a exe file name... search once again :-)
kostamaniaAuthor Commented:
i've fond this
function GetExeType(exefile: string) : TExeType;
but where is the handle ?
Lukasz LachCommented:
nope :-)
using GetProcessList where every record in result has a name variable, that is the exe file name...

TProcessList = array of record
  pid       : cardinal;
  name      : string;  // EXE File Name
  exeType   : TExeType;
  threads   : TThreadList;

There is no such thing like 'exe handle'. There are process handles, thread handles, window handles, etc. What you are looking for (IMHO) is a process handle which corresponds to a specific exe name you know beforehand. You may find one process, many processes or nothing. Nothing and one is OK (easy to handle with) but what if you find many instances of one program running at the same time?

Another point is that 'Not Responding' status simply means that a process haven't managed its message queue for a relatively long period of time. It's not guaranteed that this process is not working anymore. This depends on the programmer who wrote it. Let's suppose that this process has entered in a long and heavy loop and the developer has forgotten to add Application.ProcessMessages or similar inside that loop. The result is 'Not Responding'.

I agree with anAKiN. Madshi's enumStuff is the best choise to go. It works on all Windows versions.

Regards, Geo
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:
       to accept anAKiN's answer
Please leave any comments here within the next seven days.


Merry Christmas and happy new year!

EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.