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. WM_POWERBROADCAST on Vista.

WM_POWERBROADCAST on Vista.

Scheduled Pinned Locked Moved C / C++ / MFC
javavisual-studiocomquestion
5 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.
  • C Offline
    C Offline
    Comp_Users
    wrote on last edited by
    #1

    I am working on Vista with VS 2005. In my application, I am handling the WM_POWERBROADCAST message and in the message handlig function, execution some code which i must execute when the system goes to hibernate or standby(sleep) mode. I find that on Vista, windows doesnot wait for the WM_POWERBROADCAST message handling function to return a value(true or false) before proceeding to entering into sleep mode. On Vista, the system goes to sleep mode even before the WM_POWERBROADCAST message handling function returns a value. And because of this, my application does not have enough time to execute code in the handler function and results in a crash. Should Windows go/not go to hibernate/sleep mode depending on the return value of the WM_POWERBROADCAST handling function?[MSDN Link]

    _ 1 Reply Last reply
    0
    • C Comp_Users

      I am working on Vista with VS 2005. In my application, I am handling the WM_POWERBROADCAST message and in the message handlig function, execution some code which i must execute when the system goes to hibernate or standby(sleep) mode. I find that on Vista, windows doesnot wait for the WM_POWERBROADCAST message handling function to return a value(true or false) before proceeding to entering into sleep mode. On Vista, the system goes to sleep mode even before the WM_POWERBROADCAST message handling function returns a value. And because of this, my application does not have enough time to execute code in the handler function and results in a crash. Should Windows go/not go to hibernate/sleep mode depending on the return value of the WM_POWERBROADCAST handling function?[MSDN Link]

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      The following is from the documentation - To prevent the system from transitioning to a low-power state in Windows Vista, an application must call SetThreadExecutionState to inform the system that it is in use.

      «_Superman_» I love work. It gives me something to do between weekends.

      C 1 Reply Last reply
      0
      • _ _Superman_

        The following is from the documentation - To prevent the system from transitioning to a low-power state in Windows Vista, an application must call SetThreadExecutionState to inform the system that it is in use.

        «_Superman_» I love work. It gives me something to do between weekends.

        C Offline
        C Offline
        Comp_Users
        wrote on last edited by
        #3

        I tried calling the SetThreadExecutionState() function in the OnInitDialog() of an sample dialog based applicaiton with various combinations of flags ES_CONTINUOUS ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED, but to no avail. Could you please tell me as to which flag is to be used with SetThreadExecutionState()?

        _ 1 Reply Last reply
        0
        • C Comp_Users

          I tried calling the SetThreadExecutionState() function in the OnInitDialog() of an sample dialog based applicaiton with various combinations of flags ES_CONTINUOUS ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED, but to no avail. Could you please tell me as to which flag is to be used with SetThreadExecutionState()?

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          I guess you have to call SetThreadExecutionState inside the WM_POWERBROADCAST handler.

          «_Superman_» I love work. It gives me something to do between weekends.

          C 1 Reply Last reply
          0
          • _ _Superman_

            I guess you have to call SetThreadExecutionState inside the WM_POWERBROADCAST handler.

            «_Superman_» I love work. It gives me something to do between weekends.

            C Offline
            C Offline
            Comp_Users
            wrote on last edited by
            #5

            Tried adding the SetThreadExecutionState() funciton in the WM_POWERBROADCAST handling funciton but to no avail.

            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