How to Close Parent Program using child Program?

This is a discussion on How to Close Parent Program using child Program? within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, I had create a gui program to call another exe file, therefore I am wondering is there anyway ...

  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
    Posts
    22,888
    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
    1,678

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, 11:52 AM
  2. Scale MDI child to parent
    By bludstayne in forum C# Programming
    Replies: 0
    Last Post: 07-10-2004, 03: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, 01: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, 06:38 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21