Solved

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

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

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

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

20 Experts available now in Live!

Get 1:1 Help Now