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. Self terminating/Killing application

Self terminating/Killing application

Scheduled Pinned Locked Moved C / C++ / MFC
help
16 Posts 9 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 Ravi Jadhav

    I have a requirement to create an application which will accept the command line parameter. Depening on the parameter passed to the application, it will start and stop. For Ex. on command prompt C:\>MyExe start This command will start the application for a given task. C:\>MyExe stop If MyExe is already running then the above command will stop it. Appreciate your help.

    T Offline
    T Offline
    ThatsAlok
    wrote on last edited by
    #4

    Ravi Jadhav wrote:

    If MyExe is already running then the above command will stop it.

    do you want to create service!

    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

    cheers, Alok Gupta VC Forum Q&A :- I/ IV

    R 1 Reply Last reply
    0
    • C Cedric Moonen

      What is the type of application ? Console, Win32, MFC, ... Your question is not very clear.


      Cédric Moonen Software developer
      Charting control

      R Offline
      R Offline
      Ravi Jadhav
      wrote on last edited by
      #5

      It would be Win32 or MFC application

      N 1 Reply Last reply
      0
      • M Michael Dunn

        Ravi Jadhav wrote:

        C:\>MyExe stop

        That will run a second instance of MyExe. You'll need to use IPC to look for a running instance and tell it to stop its work.

        --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

        R Offline
        R Offline
        Ravi Jadhav
        wrote on last edited by
        #6

        I dont want the second instance. Can you please help me how to use IPC?

        M 1 Reply Last reply
        0
        • R Ravi Jadhav

          It would be Win32 or MFC application

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #7

          ::PostQuitMessage() :~


          Nibu thomas Software Developer Faqs by Michael dunn

          1 Reply Last reply
          0
          • T ThatsAlok

            Ravi Jadhav wrote:

            If MyExe is already running then the above command will stop it.

            do you want to create service!

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            R Offline
            R Offline
            Ravi Jadhav
            wrote on last edited by
            #8

            It would be Win32 or MFC application

            T 1 Reply Last reply
            0
            • R Ravi Jadhav

              I dont want the second instance. Can you please help me how to use IPC?

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #9

              Start by searching for "single instance" here - that will show you how to tell if another instance is runing.

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

              1 Reply Last reply
              0
              • R Ravi Jadhav

                I have a requirement to create an application which will accept the command line parameter. Depening on the parameter passed to the application, it will start and stop. For Ex. on command prompt C:\>MyExe start This command will start the application for a given task. C:\>MyExe stop If MyExe is already running then the above command will stop it. Appreciate your help.

                A Offline
                A Offline
                Anilkumar K V
                wrote on last edited by
                #10

                Create some gloabl object like NamedPipe, Mutux etc to manage single instance Use PostQuitMessage to exit

                1 Reply Last reply
                0
                • R Ravi Jadhav

                  I have a requirement to create an application which will accept the command line parameter. Depening on the parameter passed to the application, it will start and stop. For Ex. on command prompt C:\>MyExe start This command will start the application for a given task. C:\>MyExe stop If MyExe is already running then the above command will stop it. Appreciate your help.

                  R Offline
                  R Offline
                  Russell
                  wrote on last edited by
                  #11

                  Could you find a simpler way to solve your problem? Example C:\>MyExe start write on a registry or on a fixed file RUN = TRUE and then the program will start C:\>MyExe stop write on a registry or on a fixed file RUN = FALSE and this instance ends The first instance, thatsometimes (like into the OnIdle function) are checking the key , understands that he needs to be closed and .... close itself:). hope that helps

                  S 1 Reply Last reply
                  0
                  • R Russell

                    Could you find a simpler way to solve your problem? Example C:\>MyExe start write on a registry or on a fixed file RUN = TRUE and then the program will start C:\>MyExe stop write on a registry or on a fixed file RUN = FALSE and this instance ends The first instance, thatsometimes (like into the OnIdle function) are checking the key , understands that he needs to be closed and .... close itself:). hope that helps

                    S Offline
                    S Offline
                    Stephen Hewitt
                    wrote on last edited by
                    #12

                    This is a poor solution as it involves polling and persistent storage. Steve

                    R 1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      This is a poor solution as it involves polling and persistent storage. Steve

                      R Offline
                      R Offline
                      Russell
                      wrote on last edited by
                      #13

                      Hi

                      Stephen Hewitt wrote:

                      poor solution as it involves polling and persistent storage

                      I know that,... I according to you:-D. But the bettest (if exist:)) solution depends on how complex is his program and how much time he coud spend on this problem. My suggestion is only an example, he probally can adapt it to his program, or it can be a way to find a more simple way. If not,...well he has many other ways, according to others resp. Bye

                      1 Reply Last reply
                      0
                      • R Ravi Jadhav

                        It would be Win32 or MFC application

                        T Offline
                        T Offline
                        ThatsAlok
                        wrote on last edited by
                        #14

                        Ravi Jadhav wrote:

                        It would be Win32 or MFC application

                        try this http://www.codeproject.com/cpp/csingleinst.asp[^]

                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                        cheers, Alok Gupta VC Forum Q&A :- I/ IV

                        R 1 Reply Last reply
                        0
                        • T ThatsAlok

                          Ravi Jadhav wrote:

                          It would be Win32 or MFC application

                          try this http://www.codeproject.com/cpp/csingleinst.asp[^]

                          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                          cheers, Alok Gupta VC Forum Q&A :- I/ IV

                          R Offline
                          R Offline
                          Ravi Jadhav
                          wrote on last edited by
                          #15

                          Thanks I think this will suffice my requirement

                          1 Reply Last reply
                          0
                          • R Ravi Jadhav

                            I have a requirement to create an application which will accept the command line parameter. Depening on the parameter passed to the application, it will start and stop. For Ex. on command prompt C:\>MyExe start This command will start the application for a given task. C:\>MyExe stop If MyExe is already running then the above command will stop it. Appreciate your help.

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

                            So what exactly is the question? You've given us a high-level overview, but nothing specific. :confused:


                            "The largest fire starts but with the smallest spark." - David Crow

                            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