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. Task Mgr message

Task Mgr message

Scheduled Pinned Locked Moved C / C++ / MFC
question
15 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.
  • P Pryabu

    Hi, If we close a window application in task manager using end process method, the applcation should get some message to close the window. Can anyone please tell me what message that window applcation will get from task manager? Thanks,

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

    I guess it is WM_CLOSE message.

    -- "Programming is an art that fights back!"

    P 1 Reply Last reply
    0
    • R rp_suman

      I guess it is WM_CLOSE message.

      -- "Programming is an art that fights back!"

      P Offline
      P Offline
      Pryabu
      wrote on last edited by
      #3

      i put breakpoint in close and destroy windows message while debugging and closed the applcation via task manager,but control is not coming to that function. The applcation closes suddenly.

      R 1 Reply Last reply
      0
      • P Pryabu

        i put breakpoint in close and destroy windows message while debugging and closed the applcation via task manager,but control is not coming to that function. The applcation closes suddenly.

        R Offline
        R Offline
        rp_suman
        wrote on last edited by
        #4

        Check this Detect closing of application from windows.

        -- "Programming is an art that fights back!"

        P 1 Reply Last reply
        0
        • R rp_suman

          Check this Detect closing of application from windows.

          -- "Programming is an art that fights back!"

          P Offline
          P Offline
          Pryabu
          wrote on last edited by
          #5

          Hi, I have added WM_ENDSESSION and WM_QUERYENDSESSION message,but still the control is not coming to that corresponding function.

          1 Reply Last reply
          0
          • P Pryabu

            Hi, If we close a window application in task manager using end process method, the applcation should get some message to close the window. Can anyone please tell me what message that window applcation will get from task manager? Thanks,

            _ Offline
            _ Offline
            _Superman_
            wrote on last edited by
            #6

            When an application is terminated using end process of task manager, the application is terminated externally. There is no message or event sent to the application. So there is no way that the application can know if such a thing is happening. Task Manager uses the TerminateProcess API with an exit code of 1 to achieve this. So the only chance you have is to hook into the TerminateProcess API.

            «_Superman_»
            I love work. It gives me something to do between weekends.

            Microsoft MVP (Visual C++)

            Polymorphism in C

            P S 2 Replies Last reply
            0
            • _ _Superman_

              When an application is terminated using end process of task manager, the application is terminated externally. There is no message or event sent to the application. So there is no way that the application can know if such a thing is happening. Task Manager uses the TerminateProcess API with an exit code of 1 to achieve this. So the only chance you have is to hook into the TerminateProcess API.

              «_Superman_»
              I love work. It gives me something to do between weekends.

              Microsoft MVP (Visual C++)

              Polymorphism in C

              P Offline
              P Offline
              Pryabu
              wrote on last edited by
              #7

              Can you please tell me how to do this?

              _ 1 Reply Last reply
              0
              • P Pryabu

                Can you please tell me how to do this?

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #8

                You shouldn't have the need to do this. Why do you want to do it. API hooking is not recommended by Microsoft and will not work properly from Vista onwards. Here are a few links on how it is done - Detours[^] API hooking revealed[^] API Hooking with MS Detours[^] Win32 API hooking: Another reason why it might not work[^]

                «_Superman_»
                I love work. It gives me something to do between weekends.

                Microsoft MVP (Visual C++)

                Polymorphism in C

                P Richard Andrew x64R 2 Replies Last reply
                0
                • _ _Superman_

                  You shouldn't have the need to do this. Why do you want to do it. API hooking is not recommended by Microsoft and will not work properly from Vista onwards. Here are a few links on how it is done - Detours[^] API hooking revealed[^] API Hooking with MS Detours[^] Win32 API hooking: Another reason why it might not work[^]

                  «_Superman_»
                  I love work. It gives me something to do between weekends.

                  Microsoft MVP (Visual C++)

                  Polymorphism in C

                  P Offline
                  P Offline
                  Pryabu
                  wrote on last edited by
                  #9

                  i need to send some information to server while client application crashes. So that only im asking.

                  R 1 Reply Last reply
                  0
                  • P Pryabu

                    i need to send some information to server while client application crashes. So that only im asking.

                    R Offline
                    R Offline
                    rakesh5454
                    wrote on last edited by
                    #10

                    Either hook TerminateProcess API or make it as your design limitation. Another way is to make a service or another application which will continuously monitor your client application and once it has been closed from Task Manager, that service or application should send signal to your server.

                    f

                    P 1 Reply Last reply
                    0
                    • R rakesh5454

                      Either hook TerminateProcess API or make it as your design limitation. Another way is to make a service or another application which will continuously monitor your client application and once it has been closed from Task Manager, that service or application should send signal to your server.

                      f

                      P Offline
                      P Offline
                      Pryabu
                      wrote on last edited by
                      #11

                      thanks for all answer ...

                      1 Reply Last reply
                      0
                      • _ _Superman_

                        You shouldn't have the need to do this. Why do you want to do it. API hooking is not recommended by Microsoft and will not work properly from Vista onwards. Here are a few links on how it is done - Detours[^] API hooking revealed[^] API Hooking with MS Detours[^] Win32 API hooking: Another reason why it might not work[^]

                        «_Superman_»
                        I love work. It gives me something to do between weekends.

                        Microsoft MVP (Visual C++)

                        Polymorphism in C

                        Richard Andrew x64R Offline
                        Richard Andrew x64R Offline
                        Richard Andrew x64
                        wrote on last edited by
                        #12

                        «_Superman_» wrote:

                        will not work properly from Vista onwards.

                        Why do you say it won't work from Vista onward? I have a hooking library that works just fine in Vista. I agree that IAT patching is a poor way to hook, however. The Detours way is far superior.

                        _ 1 Reply Last reply
                        0
                        • Richard Andrew x64R Richard Andrew x64

                          «_Superman_» wrote:

                          will not work properly from Vista onwards.

                          Why do you say it won't work from Vista onward? I have a hooking library that works just fine in Vista. I agree that IAT patching is a poor way to hook, however. The Detours way is far superior.

                          _ Offline
                          _ Offline
                          _Superman_
                          wrote on last edited by
                          #13

                          Sorry. That is what I meant. Should have been more specific there.

                          «_Superman_»
                          I love work. It gives me something to do between weekends.

                          Microsoft MVP (Visual C++)

                          Polymorphism in C

                          1 Reply Last reply
                          0
                          • _ _Superman_

                            When an application is terminated using end process of task manager, the application is terminated externally. There is no message or event sent to the application. So there is no way that the application can know if such a thing is happening. Task Manager uses the TerminateProcess API with an exit code of 1 to achieve this. So the only chance you have is to hook into the TerminateProcess API.

                            «_Superman_»
                            I love work. It gives me something to do between weekends.

                            Microsoft MVP (Visual C++)

                            Polymorphism in C

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

                            You'd have to hook it globally, something that's hard to do. Almost all hooking methods word within a process.

                            Steve

                            1 Reply Last reply
                            0
                            • P Pryabu

                              Hi, If we close a window application in task manager using end process method, the applcation should get some message to close the window. Can anyone please tell me what message that window applcation will get from task manager? Thanks,

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

                              As has been said, when a process is terminated it's killed with prejudice and receives no notifications. That's the purpose of TerminateProcess, to kill a process that's misbehaving and can't be trusted. Perhaps a better approach would be to use an external process to monitor the process in question.

                              Steve

                              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