Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Is it still running???

Posted on 1998-03-20
18
Medium Priority
?
252 Views
Last Modified: 2013-12-03
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.
0
Comment
Question by:BenClark
  • 8
  • 3
  • 2
  • +5
18 Comments
 
LVL 4

Expert Comment

by:tflai
ID: 1412154
Try ShellExecuteEx() and WaitForSingleObject() on the process handle.
0
 
LVL 6

Author Comment

by:BenClark
ID: 1412155
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
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1412156
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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 
LVL 6

Author Comment

by:BenClark
ID: 1412157
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
 
LVL 32

Expert Comment

by:jhance
ID: 1412158
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
 
LVL 6

Author Comment

by:BenClark
ID: 1412159
The main language I am using will not support threads.
I need a list.
Something like the windows task list.

Thanks
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 1412160
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
 
LVL 11

Expert Comment

by:alexo
ID: 1412161
What do you mean "does not support threads"?  What language is that?  What's wrong with calling BeginThread() ?
0
 
LVL 6

Author Comment

by:BenClark
ID: 1412162
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 1412163
Is there a reason you rejected my answer?

.B ekiM

0
 
LVL 6

Author Comment

by:BenClark
ID: 1412164
It is still not what I need.
I want to do the equivelant of
FindFirstProgram()
FindNextProgram()

0
 
LVL 2

Expert Comment

by:cessi0g
ID: 1412165
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
 
LVL 6

Author Comment

by:BenClark
ID: 1412166
That will work for Win95 but what about NT?

0
 
LVL 1

Expert Comment

by:dabbler
ID: 1412167
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
 
LVL 6

Author Comment

by:BenClark
ID: 1412168
Then if Mike will resubmit his answer I will give him credit.
0
 
LVL 2

Accepted Solution

by:
cessi0g earned 1000 total points
ID: 1412169
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
 
LVL 11

Expert Comment

by:mikeblas
ID: 1412170
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
 
LVL 6

Author Comment

by:BenClark
ID: 1412171
Thanks

0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question