Is it still running???

I have one application, 32 bit, which uses ShellExecute to launch other applications, 16 or 32 bit.
How can the launching application tell when the launched application is finished.
The handle returned from ShellExecute doesn't seem to help.
LVL 6
BenClarkAsked:
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.

tflaiCommented:
Try ShellExecuteEx() and WaitForSingleObject() on the process handle.
0
BenClarkAuthor Commented:
That does work but I need to do other work while the second application is running. In fact, the first application will be launching one or MORE applications at the same time.
Some apps could be 16 bits and some could be 32 bits.
I need a way of getting a list of running apps so the calling application can check every so often.

0
Tommy HuiEngineerCommented:
If you're using Windows 95, you can use Process32Fist() and Process32Next().

If you're using Windows NT, you have to walk down the performance registry key at

  HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\currentversion\perflib

to get the list of running tasks.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

BenClarkAuthor Commented:
Could you give me a little more info on the NT route.
I got the Win95 route. Thanks
I increased the points for all your help.
Thanks
0
jhanceCommented:
The earlier answer:

Try ShellExecuteEx() and WaitForSingleObject() on the process handle.

will work but if you need to do other things.  Call ShellExecuteEx() in a thread that can then wait on the process with WaitForSingleObject()
0
BenClarkAuthor Commented:
The main language I am using will not support threads.
I need a list.
Something like the windows task list.

Thanks
0
mikeblasCommented:
You can still use WaitForSingleObject() while you're doing other stuff: just supply a timeout of zero milliseconds.  If the call returns successfully, then the application is no longer running. If the call returns with a timeout, the application is still running.

You can do this in response to a timer, if you want.

.B ekiM
0
alexoCommented:
What do you mean "does not support threads"?  What language is that?  What's wrong with calling BeginThread() ?
0
BenClarkAuthor Commented:
The language is PowerBuilder 6.
It will not handle Enums, Callbacks or Threads.
Even though I can call BeginThread(), I can't get the
function address from PowerBuilder to pass to BeginThread().

0
mikeblasCommented:
Is there a reason you rejected my answer?

.B ekiM

0
BenClarkAuthor Commented:
It is still not what I need.
I want to do the equivelant of
FindFirstProgram()
FindNextProgram()

0
cessi0gCommented:
I never used PowerBuilder but I think that's possible to call a
DLL, so you can write a DLL which inspects Internal Process Database (using Process32First and so on from Toolhelp DLL).
You can pass a pointer variable to your DLL which on return
contents address of a list of processes or threads.
I'm currently using a DLL like this written in Visual C++.
If this what's your looking for, then I can post the code.
But the most important thing is that PowerBuilder can call DLL's written in C.
0
BenClarkAuthor Commented:
That will work for Win95 but what about NT?

0
dabblerCommented:
Mike B.'s answer is good--just keep your own list of processes that you've started.  Whenever you want to know which of those processes is done, call WaitForSingleObject () on each of their handles.
0
BenClarkAuthor Commented:
Then if Mike will resubmit his answer I will give him credit.
0
cessi0gCommented:
As Thui said, you have to walk thru perfomance data in Windows NT registry to get a list of processes.
Have you have a look at Matt Pietrek's articles on Microsoft
Developer's Journal? Starting at March 1996 issue, Matt describes the way to obtain this in is colummn "Under de Hood".

0

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
mikeblasCommented:
If you've got the handle to the process you created (which ShellExecuteEx() gives you), you can use WaitForSingleObject() to see if the process has terminated or not.

If you don't know the handle, you'll have to screw around with the TOOLHELP routines. If you're using WinNT 5.0 or Win95 or Win98, TOOLHELP's the way to go. If you're using anything else, you'll have to find another way--like walking through the performance data. And that's a real chore.

It's trivial to keep the handle to the process you've started, and use it later. That'll avoid all the crazy work you'd have to do with TOOLHELP or with the performance registry entries.

.B ekiM

0
BenClarkAuthor Commented:
Thanks

0
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
Microsoft Development

From novice to tech pro — start learning today.