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. Exit an Application

Exit an Application

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 Posts 4 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.
  • P Offline
    P Offline
    punav
    wrote on last edited by
    #1

    Here I have a problem I am trying to automate Applications (FILE->EXIT) function. that is closing the application. Problem : When I open my application using createProcess() a notification is sent tat application started.But when i used following to close application no nofication is sent. if( TerminateProcess(piProcessInfo.hProcess,0)) { CloseHandle(piProcessInfo.hProcess); } This code is not acting as way as (FILE->EXIT) Please help!!! :~

    E H 2 Replies Last reply
    0
    • P punav

      Here I have a problem I am trying to automate Applications (FILE->EXIT) function. that is closing the application. Problem : When I open my application using createProcess() a notification is sent tat application started.But when i used following to close application no nofication is sent. if( TerminateProcess(piProcessInfo.hProcess,0)) { CloseHandle(piProcessInfo.hProcess); } This code is not acting as way as (FILE->EXIT) Please help!!! :~

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #2

      You say you are not able to get the process status after you call "TerminateProcess()"?

      He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

      1 Reply Last reply
      0
      • P punav

        Here I have a problem I am trying to automate Applications (FILE->EXIT) function. that is closing the application. Problem : When I open my application using createProcess() a notification is sent tat application started.But when i used following to close application no nofication is sent. if( TerminateProcess(piProcessInfo.hProcess,0)) { CloseHandle(piProcessInfo.hProcess); } This code is not acting as way as (FILE->EXIT) Please help!!! :~

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

        TerminateProcess is not good idea for close a program you can send WM_CLOSE to your program.

        Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

        P 1 Reply Last reply
        0
        • H Hamid Taebi

          TerminateProcess is not good idea for close a program you can send WM_CLOSE to your program.

          Of one Essence is the human race thus has Creation put the base One Limb impacted is sufficient For all Others to feel the Mace (Saadi )

          P Offline
          P Offline
          punav
          wrote on last edited by
          #4

          can you tell me how to do this Ex: I want to close "notepad.exe" with wm_close

          A 1 Reply Last reply
          0
          • P punav

            can you tell me how to do this Ex: I want to close "notepad.exe" with wm_close

            A Offline
            A Offline
            Akt_4_U
            wrote on last edited by
            #5

            If your target applciation has a window, you can find your target application using FindWidnow() API. This will return the window handle of the target application. Using that handle you can send WM_CLOSE message. Ex: HWND hWnd = ::FindWindow( NULL, "TargetAppName" ); ::SendMessage( hWnd, WM_CLOSE );

            akt

            P 1 Reply Last reply
            0
            • A Akt_4_U

              If your target applciation has a window, you can find your target application using FindWidnow() API. This will return the window handle of the target application. Using that handle you can send WM_CLOSE message. Ex: HWND hWnd = ::FindWindow( NULL, "TargetAppName" ); ::SendMessage( hWnd, WM_CLOSE );

              akt

              P Offline
              P Offline
              punav
              wrote on last edited by
              #6

              Thank you very much. This works fine. But say if I have 2/3 instances of same application, how do I extend this to close particular window?

              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