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. Calling one exe from other

Calling one exe from other

Scheduled Pinned Locked Moved C / C++ / MFC
c++linuxjsonquestionannouncement
8 Posts 6 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.
  • R Offline
    R Offline
    rohit dhamija 0
    wrote on last edited by
    #1

    Dear All, I am developing an application in MFC VC++ Version 6.0 for Windows 2000. How can we can one exec from another exe. ie. want to call another exe on click of a button. Is there any Shell level api available ??? (excluding WinExec) Feel free to ask any further queries in this regards, Thanks Rohit Dhamija

    M 1 Reply Last reply
    0
    • R rohit dhamija 0

      Dear All, I am developing an application in MFC VC++ Version 6.0 for Windows 2000. How can we can one exec from another exe. ie. want to call another exe on click of a button. Is there any Shell level api available ??? (excluding WinExec) Feel free to ask any further queries in this regards, Thanks Rohit Dhamija

      M Offline
      M Offline
      Magnus Westin
      wrote on last edited by
      #2

      If you mean to start another program when you click a button, then you use the CreateProcess API. If you really must use the Shell API, then its ShellExecuteEx you will need. But I would recommend that you use CreateProcess. Magnus

      A 1 Reply Last reply
      0
      • M Magnus Westin

        If you mean to start another program when you click a button, then you use the CreateProcess API. If you really must use the Shell API, then its ShellExecuteEx you will need. But I would recommend that you use CreateProcess. Magnus

        A Offline
        A Offline
        Andrew Walker
        wrote on last edited by
        #3

        Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?


        If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

        N I M V 4 Replies Last reply
        0
        • A Andrew Walker

          Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?


          If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Andrew Walker wrote: Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ? Those APIs return immediately and don't block. If you want to block till the spawned app exits, see this article :- http://www.codeproject.com/system/newbiespawn.asp[^] Nish


          Extending MFC Applications with the .NET Framework [NW] (coming soon...) Summer Love and Some more Cricket [NW] (My first novel) Shog's review of SLASMC [NW] Come with me if you want to live

          A 1 Reply Last reply
          0
          • A Andrew Walker

            Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?


            If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

            I Offline
            I Offline
            iceage
            wrote on last edited by
            #5

            you can use WaitForSingleObject or WaitForMultipleObjects

            1 Reply Last reply
            0
            • A Andrew Walker

              Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?


              If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

              M Offline
              M Offline
              Magnus Westin
              wrote on last edited by
              #6

              You can use WaitForSingleObject on the handle that is returned in PROCESS_INFORMATION::hProcess. Or you can poll with GetExitCodeProcess Magnus

              1 Reply Last reply
              0
              • N Nish Nishant

                Andrew Walker wrote: Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ? Those APIs return immediately and don't block. If you want to block till the spawned app exits, see this article :- http://www.codeproject.com/system/newbiespawn.asp[^] Nish


                Extending MFC Applications with the .NET Framework [NW] (coming soon...) Summer Love and Some more Cricket [NW] (My first novel) Shog's review of SLASMC [NW] Come with me if you want to live

                A Offline
                A Offline
                Andrew Walker
                wrote on last edited by
                #7

                Thanks Nish (& everyone else). That seemed to solve the prob


                If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

                1 Reply Last reply
                0
                • A Andrew Walker

                  Is it possible to detect whether the process has finished with either of these API's (CreateProcess / ShellExecute) ?


                  If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling

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

                  _spawnl(_P_WAIT, "c:\\mydir\\my.exe", "c:\\mydir\\my.exe", "/s", NULL); The program will not continue until my.exe has been closed. Check out this web site http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__spawn.2c_._wspawn_Functions.asp?frame=true

                  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