CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2003
    Posts
    424

    Make my code wait or loop until another program closes

    I am using ShellExecute to open a text file in notepad. I need to wait until notepad is close to continue with the execution of my program.

    What do you think is the best way to do that?

  2. #2
    Join Date
    Mar 2004
    Location
    (Upper-) Austria
    Posts
    2,899

    Re: Make my code wait or loop until another program closes

    Use ShellExecuteEx to retrieve the HINSTANCE of the application and use Wait functions on it such as WaitForSingleObject(). Just wait INFINITE and the function will only return if the application was closed.
    I am not offering technical guidiance via email or IM
    Come on share your photo with us! CG members photo album!
    Use the Code Tags!

  3. #3
    Join Date
    May 2003
    Posts
    424

    Re: Make my code wait or loop until another program closes

    MS says the HINSTANCE set is not really an HINSTANCE, it's error handling.

  4. #4
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Make my code wait or loop until another program closes

    Quote Originally Posted by NoHero
    Use ShellExecuteEx to retrieve the HINSTANCE of the application and use Wait functions on it such as WaitForSingleObject(). Just wait INFINITE and the function will only return if the application was closed.
    Well...you would not use the 'hInstApp' member of the "SHELLEXECUTEINFO' structure but rather the 'hProcess ' one...

    However, this still depends on several options you can set within the 'SHELLEXECUTEINFO' structure and thus, isn't reliable.

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: Make my code wait or loop until another program closes

    Quote Originally Posted by aewarnick
    What do you think is the best way to do that?

  6. #6
    Join Date
    May 2003
    Posts
    424

    Re: Make my code wait or loop until another program closes

    Thanks, I had it working but it looks like CreateProcess is much more reliable.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured