Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ShellExecuteEx doen't wait...

ShellExecuteEx doen't wait...

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestioncareer
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Srini Kella
    wrote on last edited by
    #1

    I have a thread which launcher another application using ShellExecuteEx(). The problem is, the calling thread is NOT wating till the new Process gets launched. Is there any way to delay the calling thread until ShellExecuteEx() finishes its job? Or is there any other solution for this??? Thanx in advance.

    J 1 Reply Last reply
    0
    • S Srini Kella

      I have a thread which launcher another application using ShellExecuteEx(). The problem is, the calling thread is NOT wating till the new Process gets launched. Is there any way to delay the calling thread until ShellExecuteEx() finishes its job? Or is there any other solution for this??? Thanx in advance.

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #2

      Srini Kella wrote: Is there any way to delay the calling thread until ShellExecuteEx() finishes its job? WaitForSingleObject() WaitForSingleObjectEx() WaitForMultipleObjects() WaitForMultipleObjectsEx() Jeremy L. Falcon Homepage : Sonork = 100.16311
      "It was a blind man who taught me how to see." - Aerosmith

      S 1 Reply Last reply
      0
      • J Jeremy Falcon

        Srini Kella wrote: Is there any way to delay the calling thread until ShellExecuteEx() finishes its job? WaitForSingleObject() WaitForSingleObjectEx() WaitForMultipleObjects() WaitForMultipleObjectsEx() Jeremy L. Falcon Homepage : Sonork = 100.16311
        "It was a blind man who taught me how to see." - Aerosmith

        S Offline
        S Offline
        Srini Kella
        wrote on last edited by
        #3

        The Wait* functions are not going to work because, once the ShellExecute returns, the corresponding new process will already be in non-signalled state. I got a work around: My new process has a got window. So, I delayed the calling thread using EnumWindows() in a loop. EnumWindows() checks for the new window!! ;P Anybody has got a better solution for this, Please!!

        J 1 Reply Last reply
        0
        • S Srini Kella

          The Wait* functions are not going to work because, once the ShellExecute returns, the corresponding new process will already be in non-signalled state. I got a work around: My new process has a got window. So, I delayed the calling thread using EnumWindows() in a loop. EnumWindows() checks for the new window!! ;P Anybody has got a better solution for this, Please!!

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #4

          It will work depending on what you want to do. If you are waiting for the process to finish, then use... WaitForSingleObject(hProcess, INFINITE); // INFINITE = -1 When the process terminates, it'll return. -1 means it'll wait indefinitely. I thought that's what you wanted, but if you only care about having the window created in the new process then see if this works... WaitForInputIdle(hProcess, INFINITE); // INFINITE = -1 Jeremy L. Falcon Homepage : Sonork = 100.16311
          "It was a blind man who taught me how to see." - Aerosmith

          S 1 Reply Last reply
          0
          • J Jeremy Falcon

            It will work depending on what you want to do. If you are waiting for the process to finish, then use... WaitForSingleObject(hProcess, INFINITE); // INFINITE = -1 When the process terminates, it'll return. -1 means it'll wait indefinitely. I thought that's what you wanted, but if you only care about having the window created in the new process then see if this works... WaitForInputIdle(hProcess, INFINITE); // INFINITE = -1 Jeremy L. Falcon Homepage : Sonork = 100.16311
            "It was a blind man who taught me how to see." - Aerosmith

            S Offline
            S Offline
            Srini Kella
            wrote on last edited by
            #5

            I am not waiting for the process to finsih. I am waiting for the process to begin 'fully' instead! Thanks anyway.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups