Thread: How to Close Parent Program using child Program?

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    58

    How to Close Parent Program using child Program?

    Hi everyone,
    I had create a gui program to call another exe file, therefore I am wondering is there anyway to keep track on the executed program so that when the user cancel it I can cancel my parent program as well.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Start the program using ShellExecuteEx or CreateProcess to attain a process handle.
    You can then check the handle using WaitForSingleObject with a wait of 0 to see if handle is signaled or not. If WaitForSingleObject returns WAIT_OBJECT_0, it means the process is still running, and if it returns WAIT_TIMEOUT, it means the program has finished executing (in this case, you should also call CloseHandle on that handle, as well).
    Or you can specify a longer wait if you want, since the app won't consume cpy cycles when it's waiting.
    Last edited by Elysia; 11-30-2007 at 02:53 AM.

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. child classes calling parent constructors (with arguments)
    By reanimated in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2006, 10:52 AM
  2. Scale MDI child to parent
    By bludstayne in forum C# Programming
    Replies: 0
    Last Post: 07-10-2004, 02:26 PM
  3. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  4. SO close to finishing chat program...!
    By Nakeerb in forum C++ Programming
    Replies: 13
    Last Post: 10-26-2002, 12:24 PM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM