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. MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]

MFC silent executable running from system account not recieveing WM_QUERYENDSESSION message ?? [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
22 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.
  • K Kushagra Tiwari

    Does anybody knows the solution ??? Kushagra

    C Offline
    C Offline
    Covean
    wrote on last edited by
    #21

    From MSDN: "Console applications receive shutdown notifications in their handler routines. To register a console handler, use the SetConsoleCtrlHandler function. Service applications receive shutdown notifications in their handler routines. To register a service control handler, use the RegisterServiceCtrlHandlerEx function." Maybe that helps.

    1 Reply Last reply
    0
    • K Kushagra Tiwari

      Hello all, I have made an MFC application with invisible window and invisible in Applications tab of taskmanager designed to run in different sessions depending upon the number of users who are logged into the system. Thus, according to user events the instances used to capture logoff/Shutdown/Logon events for that particular session.Also, I have made one instance of this executable to run in 'SYSTEM' account to capture scheduled shutdown in cases when no user was logged on the machine. However in this case 'WM_QUERYENDSESSION' is never recieved by this running instance of my application which runs in 'SYSTEM' account.Can some one tell me how to abort scheduled shutdown in Windows from an application running in system account , in a case when no user is logged on in the machine. Regards, Kushagra I hate coding but I luv to develop :)

      modified on Wednesday, October 21, 2009 9:22 AM

      R Offline
      R Offline
      Roger Stoltz
      wrote on last edited by
      #22

      Kushagra Tiwari wrote:

      I have made an MFC application with invisible window and invisible in Applications tab of taskmanager .... I have made one instance of this executable to run in 'SYSTEM' account

      Does this mean that you have created a service?

      Kushagra Tiwari wrote:

      how to abort scheduled shutdown in Windows from an application running in system account

      Are you certain that you really want to do this even if it's possible? What do you mean by 'scheduled'? Personally I find it suspicious that you have created an application that runs "invisible" from user perspective that aims to block the system from being brought down. I would consider it to be a very anti-social application that I wouldn't want running on any of my machines. However, if an application calls ::ExitWindowsEx() with the EWK_FORCE parameter, WM_QUERYENDSESSION will not be sent - all processes will be terminated and possibly with data lost. How do you distinguish from a 'scheduled' shutdown and one triggered by a user in your message handler or callback? I guess the user won't be able to bring the system down either.... What if your application runs on a machine with UPS; the power is lost and the UPS service wants to bring the system down safely? Will you block it if possible? I guess my question really is "what are to trying to accomplish and why"? There may be a better solution.

      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      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