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. How to know that application is closed. that was launched by ShellExecute()

How to know that application is closed. that was launched by ShellExecute()

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
10 Posts 7 Posters 1 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.
  • Z Offline
    Z Offline
    zahid_ash
    wrote on last edited by
    #1

    Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

    G K L S V 6 Replies Last reply
    0
    • Z zahid_ash

      Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

      G Offline
      G Offline
      Ganesh_T
      wrote on last edited by
      #2

      First of all what type of application you are creating. Here you can chect the value of handle.... check if it exist... Cheers "Peace of mind through Technology"

      Z 1 Reply Last reply
      0
      • Z zahid_ash

        Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

        K Offline
        K Offline
        khan
        wrote on last edited by
        #3

        I don't think there is an easy way to track an application. The Handle returned by ShellExecute() is not a handle, but a value. There are other ways you can track an application like: Events, Mutexes etc. this is this.

        1 Reply Last reply
        0
        • G Ganesh_T

          First of all what type of application you are creating. Here you can chect the value of handle.... check if it exist... Cheers "Peace of mind through Technology"

          Z Offline
          Z Offline
          zahid_ash
          wrote on last edited by
          #4

          Does it means that If when 2nd application is closed then the handle returned by ShellExecute will automaticlay become flase or expired or null. Regards.

          K 1 Reply Last reply
          0
          • Z zahid_ash

            Does it means that If when 2nd application is closed then the handle returned by ShellExecute will automaticlay become flase or expired or null. Regards.

            K Offline
            K Offline
            khan
            wrote on last edited by
            #5

            http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp[^] Here, in the "Return Value" section, it says: The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however this is this.

            1 Reply Last reply
            0
            • Z zahid_ash

              Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

              L Offline
              L Offline
              Laxman Auti
              wrote on last edited by
              #6

              zahid_ash wrote:

              Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage?

              You may keep track of process by enumrating the running processes in specific time stamp. Knock out 't' from can't, You can if you think you can :cool:

              1 Reply Last reply
              0
              • Z zahid_ash

                Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

                S Offline
                S Offline
                sunit5
                wrote on last edited by
                #7

                if u r application happens to be an .exe then u can get Processid.Using it u can track application B in Application A.This might help u.:(( never say die

                S 1 Reply Last reply
                0
                • Z zahid_ash

                  Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

                  V Offline
                  V Offline
                  Viorel
                  wrote on last edited by
                  #8

                  In order to see that a process was closed, you need its "handle". Please compare ShellExecuteEx and CreateProcess in order to see which is more suitable to obtain the handle. Then use the handle in the following mode:

                  if(::WaitForSingleObject(handle, 0) == WAIT_OBJECT_0)
                  {
                     // the process is closed
                  }
                  else
                  {
                     // the process is running, or an error
                  }
                  

                  If you want to wait until the process is closed, then specify a timeout value in WaitForSingleObject. See this function for more details.

                  1 Reply Last reply
                  0
                  • S sunit5

                    if u r application happens to be an .exe then u can get Processid.Using it u can track application B in Application A.This might help u.:(( never say die

                    S Offline
                    S Offline
                    sunit5
                    wrote on last edited by
                    #9

                    Process32First and Process32Next to get the Processid:-> never say die

                    1 Reply Last reply
                    0
                    • Z zahid_ash

                      Hi, I have lauchned an application B from my application A using ShellExecute() , it will return a Handle. How can I track in application A that application B is closed at certain stage? Thanks Regards.

                      2 Offline
                      2 Offline
                      224917
                      wrote on last edited by
                      #10

                      Use SHELLEXECUTEINFO with ShellExecuteEx() and the structure has a member "hProcess" this is the handle to newly created process.


                      suhredayan
                      There is no place like 127.0.0.1

                      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