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. Disable User Logoff

Disable User Logoff

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 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.
  • S Offline
    S Offline
    softwaremonkey
    wrote on last edited by
    #1

    Is there a way to prevent the user from logging off from their Windows account while my application is running?

    D S I 3 Replies Last reply
    0
    • S softwaremonkey

      Is there a way to prevent the user from logging off from their Windows account while my application is running?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Is WM_QUERYENDSESSION of any help?

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

      S 1 Reply Last reply
      0
      • S softwaremonkey

        Is there a way to prevent the user from logging off from their Windows account while my application is running?

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

        Method for XP or earlier is slightly different from Vista/Win7 from my experience. For XP or earlier, return 0 for WM_QUERYENDSESSION and this should be enough. For Vista/Win7, I haven't found a way to entirely stop logging off. But temporarily blocking logging off is possible. I would return 1 for WM_QUERYENDSESSION and register a blocking reason during WM_ENDSESSION, by calling ShutdownBlockReasonCreate. Then call ShutdownBlockReasonDestroy when your application is finished running. You should obey the description mentioned in WM_ENDSESSION Message[^] and WM_QUERYENDSESSION[^] to make sure both user and Windows system are happy.

        1 Reply Last reply
        0
        • D David Crow

          Is WM_QUERYENDSESSION of any help?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          S Offline
          S Offline
          softwaremonkey
          wrote on last edited by
          #4

          Yea thanks, I had forgotten about that mesage and it did the trick. Thanks again :thumbsup: :thumbsup:

          1 Reply Last reply
          0
          • S softwaremonkey

            Is there a way to prevent the user from logging off from their Windows account while my application is running?

            I Offline
            I Offline
            Iain Clarke Warrior Programmer
            wrote on last edited by
            #5

            Are you paying for their computer? Iain.

            I am one of "those foreigners coming over here and stealing our jobs". Yay me!

            S 1 Reply Last reply
            0
            • I Iain Clarke Warrior Programmer

              Are you paying for their computer? Iain.

              I am one of "those foreigners coming over here and stealing our jobs". Yay me!

              S Offline
              S Offline
              softwaremonkey
              wrote on last edited by
              #6

              He he, no but the PC is running an important control system that the normal user is not authorised to shut down. However, if the user logs off, it closes my application.

              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