Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

delphi XE6 run external application wait untill its done, then goes to the next.

delphi xe6 launch applications

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 gobroski


    CC Lurker

  • New Member
  • Pip
  • 4 posts

Posted 17 May 2014 - 12:12 AM

Greetings!  I am writing an application that downloads programs from the internet, and then launches them.  Now I have the downloading and running parst done, I am just unsure on how I can make my program launch the next one once the first one is complete.  


Thank you for any ideas.  I was thinking that it has to do with handles, or processes using wmic features.


Have a good night 



#2 gonerogue


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 197 posts

Posted 17 May 2014 - 12:35 AM

Disclaimer: I don't know Delphi. But, using Winapi, you would do as follows:


1. To create a process you would use CreateProcess() function:



2. Pay atention at the last parameter of CreateProcessLPPROCESS_INFORMATION lpProcessInformation.

You can see details about the LPPROCESS_INFORMATION structure here: http://msdn.microsof...3(v=vs.85).aspx

The first member in the structure LPPROCESS_INFORMATION contains a handle to the process you have started.

So, this way you obtain a handle to the process you have started.


3. To wait for the launched process to finish, use the WaitForSimpleObject() function on the process handle, with second parameter set to INFINITE

It is described here:



4. After the process finished, you can get its exit code using the 

GetExitCodeProcess() function.



5. After that, you should close the handle to the process by using the CloseHandle() function.



6. Launch the next process ...


It should be fairly easy to translate this to Delphi.


Good luck.

Edited by gonerogue, 17 May 2014 - 12:54 AM.

#3 gobroski


    CC Lurker

  • New Member
  • Pip
  • 4 posts

Posted 17 May 2014 - 12:54 AM

Thank you for the super fast response...  I will let you know what I come up with!


Thanks again! 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download