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 launch a second application?

How to launch a second application?

Scheduled Pinned Locked Moved C / C++ / MFC
questionperformancetutorialcareer
7 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.
  • I Offline
    I Offline
    IlanTal
    wrote on last edited by
    #1

    I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

    L H D S I 6 Replies Last reply
    0
    • I IlanTal

      I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      EnumProcesses

      led mike

      1 Reply Last reply
      0
      • I IlanTal

        I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

        H Offline
        H Offline
        Hamid Taebi
        wrote on last edited by
        #3

        IlanTal wrote:

        I don't want to launch multiple instances of it

        See this[^] thread for your question and you said you used of WinExec,its of MSDN : "This function is provided only for compatibility with 16-bit Windows. Applications should use the CreateProcess function"


        WhiteSky


        1 Reply Last reply
        0
        • I IlanTal

          I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          IlanTal wrote:

          So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple.

          See here.

          IlanTal wrote:

          Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this?

          See here.


          "A good athlete is the result of a good and worthy opponent." - David Crow

          "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

          1 Reply Last reply
          0
          • I IlanTal

            I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

            S Offline
            S Offline
            SandipG
            wrote on last edited by
            #5

            You can use CreateProcess or ShellExecute or ShellExecuteEx depending on ur req.

            1 Reply Last reply
            0
            • I IlanTal

              I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

              I Offline
              I Offline
              IlanTal
              wrote on last edited by
              #6

              Thanks to all for the replies. It is nice to receive so many replies. They were useful and the problem is now solved (using a mutex). Ilan

              1 Reply Last reply
              0
              • I IlanTal

                I have a program where sometimes I need a button to launch a different program. I used WinExec() for the job, even though I get the impression that it is out of date and I should be using something else. So, first of all, if there is a better choice, please let me know. WinExec() does the job nicely since it is so simple. Here is my real question. The second application takes a lot of memory and I don't want to launch multiple instances of it. So I would like something to check to see if it is running. If not, launch it. If yes, jump to the instance which is running. Is there an easy way to do this? Thanks, Ilan

                realJSOPR Offline
                realJSOPR Offline
                realJSOP
                wrote on last edited by
                #7

                Use CreateProcess() and keep the handle around. If the handle is NULL, don't let the program be executed again.

                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
                -----
                "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

                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