Solved

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

Posted on 1998-01-25
4
163 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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