Solved

Is it still running???

Posted on 1998-03-20
18
222 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 500 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now