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. Visual Basic
  4. how to detect app killing

how to detect app killing

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
8 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.
  • E Offline
    E Offline
    edwin164
    wrote on last edited by
    #1

    Does anybody know how to detect that an app is being killing?? some games, like command & conquers show you a dialog to close when you try to kill from process list. is there a windows message (other than WM_CLOSE) that can tell me that my app is being killing??? modif: am using VB6 -------------------------- there's another hope... -- modified at 15:28 Wednesday 11th January, 2006

    J B 2 Replies Last reply
    0
    • E edwin164

      Does anybody know how to detect that an app is being killing?? some games, like command & conquers show you a dialog to close when you try to kill from process list. is there a windows message (other than WM_CLOSE) that can tell me that my app is being killing??? modif: am using VB6 -------------------------- there's another hope... -- modified at 15:28 Wednesday 11th January, 2006

      J Offline
      J Offline
      Joshua Quick
      wrote on last edited by
      #2

      If you're talking about a VB.NET WinForm app, then you need to handle the form's "Closing" event. If this is a VB6 app, then you need to catch the "Form_QueryUnload" event. -- modified at 14:12 Wednesday 11th January, 2006

      E 1 Reply Last reply
      0
      • E edwin164

        Does anybody know how to detect that an app is being killing?? some games, like command & conquers show you a dialog to close when you try to kill from process list. is there a windows message (other than WM_CLOSE) that can tell me that my app is being killing??? modif: am using VB6 -------------------------- there's another hope... -- modified at 15:28 Wednesday 11th January, 2006

        B Offline
        B Offline
        Briga
        wrote on last edited by
        #3

        edwin164 wrote:

        is there a windows message (other than WM_CLOSE) that can tell me that my app is being killing???

        AFAIK that's the only WM message. In the beginning the OS tries to close it in a polite way sending that message. Still you don't need to intercept the message since the framework provides you with a pre-built event for each form (Closing). That event allows you to cancel the closing with the Cancel argument. If the form is mandatory closed by an external event (OS) again the FW should give you the event Closed.

        E 1 Reply Last reply
        0
        • B Briga

          edwin164 wrote:

          is there a windows message (other than WM_CLOSE) that can tell me that my app is being killing???

          AFAIK that's the only WM message. In the beginning the OS tries to close it in a polite way sending that message. Still you don't need to intercept the message since the framework provides you with a pre-built event for each form (Closing). That event allows you to cancel the closing with the Cancel argument. If the form is mandatory closed by an external event (OS) again the FW should give you the event Closed.

          E Offline
          E Offline
          edwin164
          wrote on last edited by
          #4

          am using VB6 so no framework is available... :( i wondering how some apps (probably not written in VB) can intercept a process killing. not using forms event is there another way to execute code before process die??

          D B 2 Replies Last reply
          0
          • J Joshua Quick

            If you're talking about a VB.NET WinForm app, then you need to handle the form's "Closing" event. If this is a VB6 app, then you need to catch the "Form_QueryUnload" event. -- modified at 14:12 Wednesday 11th January, 2006

            E Offline
            E Offline
            edwin164
            wrote on last edited by
            #5

            am using VB6, but without form events, is there a way to detect a process killing, to show a dialog or execute code?? i see this in some games, i wonder how the program do not terminate but show a dialog asking you to confirm program exit.

            J 1 Reply Last reply
            0
            • E edwin164

              am using VB6 so no framework is available... :( i wondering how some apps (probably not written in VB) can intercept a process killing. not using forms event is there another way to execute code before process die??

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              No, there is no way to trap this without the "event". You're application get's sent a WM_CLOSE message. This shows up in your app as the form Closing event. Handle this event. You DON'T have to return a response immediately, Windows will wait for around for a response. When this event happens, you can put up your dialog. In response to the dialog, you can then respond to the Closing event by setting the Cancel property appropariately. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              • E edwin164

                am using VB6, but without form events, is there a way to detect a process killing, to show a dialog or execute code?? i see this in some games, i wonder how the program do not terminate but show a dialog asking you to confirm program exit.

                J Offline
                J Offline
                Joshua Quick
                wrote on last edited by
                #7

                edwin164 wrote:

                i see this in some games, i wonder how the program do not terminate but show a dialog asking you to confirm program exit.

                I would expect a game to make calls to PeekMessage() within the game loop. It would need to do this to receive keyboard and mouse input. It would also catch the window's WM_CLOSE and maybe the WM_QUIT events as well, allowing the game to close itself gracefully. You need the window's handle in order to receive its messages. Once you receive the WM_CLOSE message, you can display your confirmation dialog. You would call DestroyWindow(hWnd) to close it afterwards, if you're doing it via Win32 API.

                1 Reply Last reply
                0
                • E edwin164

                  am using VB6 so no framework is available... :( i wondering how some apps (probably not written in VB) can intercept a process killing. not using forms event is there another way to execute code before process die??

                  B Offline
                  B Offline
                  Briga
                  wrote on last edited by
                  #8

                  in VB6 the event is Form_Unload but it looks like you don't have a running form. If that's the case you have to check your messaging queue for the WM_CLOSE and WM_QUIT

                  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