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 CLOSE AN APP WITH ANOTHER

HOW TO CLOSE AN APP WITH ANOTHER

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
7 Posts 5 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.
  • C Offline
    C Offline
    Cheickna
    wrote on last edited by
    #1

    Hi, I have two applications and want to close one by clicking on command button from the other application. I know that i must use theses functions : CreateMutex, OpenMutex, FindWindow , ... But i don't know how to realize this action Can anybody help me . Thanks in advance

    R A N 3 Replies Last reply
    0
    • C Cheickna

      Hi, I have two applications and want to close one by clicking on command button from the other application. I know that i must use theses functions : CreateMutex, OpenMutex, FindWindow , ... But i don't know how to realize this action Can anybody help me . Thanks in advance

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Do you own the two applications ? Or do you want to kill a third party application from your own application ? ~RaGE();

      C 1 Reply Last reply
      0
      • R Rage

        Do you own the two applications ? Or do you want to kill a third party application from your own application ? ~RaGE();

        C Offline
        C Offline
        Cheickna
        wrote on last edited by
        #3

        No i don't want to kill a third party application. The two application are mine ( created with visual C++6.0) Thanks

        R 1 Reply Last reply
        0
        • C Cheickna

          Hi, I have two applications and want to close one by clicking on command button from the other application. I know that i must use theses functions : CreateMutex, OpenMutex, FindWindow , ... But i don't know how to realize this action Can anybody help me . Thanks in advance

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          HWND hWnd = ::FindWindowEx(NULL, NULL, NULL, "Calculator" ); if (!hWnd) { AfxMessageBox("Could not find \"Calculator\" window"); return; } else ::PostMessage(hWnd, WM_CLOSE, 0, 0);

          J 1 Reply Last reply
          0
          • C Cheickna

            Hi, I have two applications and want to close one by clicking on command button from the other application. I know that i must use theses functions : CreateMutex, OpenMutex, FindWindow , ... But i don't know how to realize this action Can anybody help me . Thanks in advance

            N Offline
            N Offline
            Neville Franks
            wrote on last edited by
            #5

            If you can get a handle to the other app the SedMessage( .. WM_CLOSE .. ) or something like that should work fine. Please don't SHOUT at us. Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com

            1 Reply Last reply
            0
            • C Cheickna

              No i don't want to kill a third party application. The two application are mine ( created with visual C++6.0) Thanks

              R Offline
              R Offline
              Rage
              wrote on last edited by
              #6

              Then use a user defined message (search for this here on CP or in MSDN), and use SendMessage() or PostMessage() in the first application to send it to your second application. In your second application (the one which ought to be terminated), handle your message in the message map, and end your application calling DestroyWindow() or OnOK() if it is a MFC dialog. ~RaGE();

              1 Reply Last reply
              0
              • A Anonymous

                HWND hWnd = ::FindWindowEx(NULL, NULL, NULL, "Calculator" ); if (!hWnd) { AfxMessageBox("Could not find \"Calculator\" window"); return; } else ::PostMessage(hWnd, WM_CLOSE, 0, 0);

                J Offline
                J Offline
                John M Drescher
                wrote on last edited by
                #7

                This is the easiest way in most cases. John

                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