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. System shutdown behaviour?

System shutdown behaviour?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 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.
  • S Offline
    S Offline
    Surender
    wrote on last edited by
    #1

    I am responding to system shut down with the help of WM_QUERYENDSESSION but the problem is before i respond to this message some applications are being closed which are sitting in the Task bar tray and also some open applications in the task bar.I don't want this to happen.Is there any way to be the first in trapping WM_QUERYENDSESSION session and avoid other applications being killed.

    J S 2 Replies Last reply
    0
    • S Surender

      I am responding to system shut down with the help of WM_QUERYENDSESSION but the problem is before i respond to this message some applications are being closed which are sitting in the Task bar tray and also some open applications in the task bar.I don't want this to happen.Is there any way to be the first in trapping WM_QUERYENDSESSION session and avoid other applications being killed.

      J Offline
      J Offline
      Joaquin M Lopez Munoz
      wrote on last edited by
      #2

      You can intercept (and block) this message by installing a system-wide hook with [SetWindowsHookEx](http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/CommCtls/winui/hooks_7vaw.asp). Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

      1 Reply Last reply
      0
      • S Surender

        I am responding to system shut down with the help of WM_QUERYENDSESSION but the problem is before i respond to this message some applications are being closed which are sitting in the Task bar tray and also some open applications in the task bar.I don't want this to happen.Is there any way to be the first in trapping WM_QUERYENDSESSION session and avoid other applications being killed.

        S Offline
        S Offline
        Surender
        wrote on last edited by
        #3

        Below is the code snippet i used for HOOKING the WM_QUERYENDSESSION.But i never see the message box i am displaying. 1.Is there any problem with the below code 2.Also how can i discard the WM_QUERYENDSESSION at this moment so that it will not reach other applications. DLL_EXPORT void SetHook(void) { if(!bHooked) { hhook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)MsgProc, hInst, (DWORD)NULL); bHooked = TRUE; } } LRESULT CALLBACK MsgProc(int code, WPARAM wParam, LPARAM lParam) { MSG* msg; msg = (MSG*) lParam; if( code >= 0 ) { if( msg->message == WM_QUERYENDSESSION) { MessageBox( NULL , "Recieved WM_QUERYENDSESSION" , "test" , MB_OK|MB_APPLMODAL|MB_SETFOREGROUND|MB_TOPMOST ); } } return CallNextHookEx(hhook, code, wParam, lParam) ; }

        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