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 stop another exe from current project.

How to stop another exe from current project.

Scheduled Pinned Locked Moved C / C++ / MFC
question
10 Posts 7 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
    shivditya
    wrote on last edited by
    #1

    I have a one exe running how can I terminate it through another project.

    || ART OF LIVING ||

    N J H 4 Replies Last reply
    0
    • S shivditya

      I have a one exe running how can I terminate it through another project.

      || ART OF LIVING ||

      N Offline
      N Offline
      nbugalia
      wrote on last edited by
      #2

      Use EnumProcesses, GetModuleFileNameExA, GetModuleBaseNameA, EnumProcessModules to get proper process handle. Then use ::TerminateProcess.

      D 1 Reply Last reply
      0
      • S shivditya

        I have a one exe running how can I terminate it through another project.

        || ART OF LIVING ||

        J Offline
        J Offline
        JudyL_MD
        wrote on last edited by
        #3

        TerminateProcess is the function of last resort. Try something "nice" first, like sending it a WM_CLOSE message.

        1 Reply Last reply
        0
        • S shivditya

          I have a one exe running how can I terminate it through another project.

          || ART OF LIVING ||

          N Offline
          N Offline
          nbugalia
          wrote on last edited by
          #4

          Use FindWindow to get the handle of the window you want to close. Send WM_CLOSE message to this window.

          1 Reply Last reply
          0
          • N nbugalia

            Use EnumProcesses, GetModuleFileNameExA, GetModuleBaseNameA, EnumProcessModules to get proper process handle. Then use ::TerminateProcess.

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

            NishantB++ wrote:

            Then use ::TerminateProcess.

            And what if that process is doing something important? TerminateProcess() should be used as a last resort.


            "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

            L 1 Reply Last reply
            0
            • D David Crow

              NishantB++ wrote:

              Then use ::TerminateProcess.

              And what if that process is doing something important? TerminateProcess() should be used as a last resort.


              "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

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

              DavidCrow wrote:

              TerminateProcess() should be used as a last resort.

              Or when your desired goal is to build a frail brittle software system... could happen.

              M 1 Reply Last reply
              0
              • L led mike

                DavidCrow wrote:

                TerminateProcess() should be used as a last resort.

                Or when your desired goal is to build a frail brittle software system... could happen.

                M Offline
                M Offline
                Mark Salsbery
                wrote on last edited by
                #7

                led mike wrote:

                ... could happen

                I'll go farther and say it happens often :)

                Mark Salsbery Microsoft MVP - Visual C++ :java:

                1 Reply Last reply
                0
                • S shivditya

                  I have a one exe running how can I terminate it through another project.

                  || ART OF LIVING ||

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

                  You can send WM_CLOSE.

                  S 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    You can send WM_CLOSE.

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

                    Thanks everyone for sending reply,I will try sending WM_CLOSE

                    || ART OF LIVING ||

                    H 1 Reply Last reply
                    0
                    • S shivditya

                      Thanks everyone for sending reply,I will try sending WM_CLOSE

                      || ART OF LIVING ||

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

                      I hope it solved your problem.:)

                      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