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. Windows Development
  4. which function gets called in case of End Task for process running in Background

which function gets called in case of End Task for process running in Background

Scheduled Pinned Locked Moved Windows Development
debuggingtutorialquestion
3 Posts 3 Posters 18 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.
  • N Offline
    N Offline
    N3KK
    wrote on last edited by
    #1

    Hi there, I have my Tray application running as Background process in Win8 When I click for End task from Task Manager, how to get notified for End Task call. (which function is called??) (In case of GUI application WM_CLOSE gets called but I couldn't able to trace for this.) -Thanks

    Richard DeemingR L 2 Replies Last reply
    0
    • N N3KK

      Hi there, I have my Tray application running as Background process in Win8 When I click for End task from Task Manager, how to get notified for End Task call. (which function is called??) (In case of GUI application WM_CLOSE gets called but I couldn't able to trace for this.) -Thanks

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Raymond Chen has the answer:

      Why can't you trap TerminateProcess?[^]

      If a user fires up Task Manager and clicks "End Task" on your program, Windows first tries to shut down your program nicely, by sending WM_CLOSE messages to GUI programs and CTRL_CLOSE_EVENT events to console programs. But you don't get a chance to intercept TerminateProcess.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • N N3KK

        Hi there, I have my Tray application running as Background process in Win8 When I click for End task from Task Manager, how to get notified for End Task call. (which function is called??) (In case of GUI application WM_CLOSE gets called but I couldn't able to trace for this.) -Thanks

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        It can be one of three applications; A windows service; in that case, it would have an event that is raised. Should not show a UI. A console application; would not show a tray icon A windows GUI application; regardless of whether you show a form, it still is a GUI application. Keep a form open (something I'd expect from the Application.Run(formName) call) and make it invisible.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

        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