Solved

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

Posted on 1998-01-25
4
164 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
[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
  • 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 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