Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Is it still running???

Posted on 1998-03-20
18
Medium Priority
?
248 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…

704 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