Solved

´"Stop" motherapp. after launching with Createprocess..

Posted on 1998-01-25
4
162 Views
Last Modified: 2010-04-04
I use Createprocess to launch an external application. However, I want the "Mother-process" (the app. that I use to Launch) to execute some lines of code after the launched application is closed..

Like this:

Procedure Form1.Button1Click(Sender: TObject);
// Var declaration..
Begin
Createprocess(PChar(Process_To_Launch),NIL,NIL,NIL,False,
Normal_Priority_Class,NIL,Startup_Info,Process_Info);

// some lines of code that I want to be executed after the
// Process_To_Launch is closed down.
// For example:

ShowMessage('The Process is closed down');

End;

The problem is that the external application is launched,
and then the following rows of code is executed directly,
Without waiting for the launched application to finish..

Is this the way to do it, or do I have to create some event-
handling for this, in short: How do I do it?

I use Delphi Developer 2.0
Thanks!
Erik N
0
Comment
Question by:Erik N
  • 3
4 Comments
 

Author Comment

by:Erik N
ID: 1357522
Edited text of question
0
 

Author Comment

by:Erik N
ID: 1357523
Edited text of question
0
 
LVL 5

Accepted Solution

by:
inter earned 140 total points
ID: 1357524
Dear friend,

Use the following function and loop to wait for the process termination:(The Process_Info structure is the one you obtained by CreateProcess)

 repeat
   GetExitCodeProcess(Process_Info.hProcess, lpExitCode);
   Application.ProcessMessages;
 until (lpExitCode <> STILL_ACTIVE);

 // Your code goes here (after process terminated)

 May it helps,
 Igor
0
 

Author Comment

by:Erik N
ID: 1357525
It worked just fine!
Thank you Inter-Igor!

Erik N
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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