none
PowerSettingRegisterNotification Not working on Windows 7 RRS feed

  • Question

  • Dear all,

    In my application I have used PowerSettingRegisterNotification function for registering for Monitor Screen state notification as below.

       

    static_DEVICE_NOTIFY_SUBSCRIBE_PARAMETERSScreenEventParams = {

                                                                        isConnectedStandby,

                                                                        pDevContext

                                                                        };

        retResult = PowerSettingRegisterNotification(

                                                     &GUID_CONSOLE_DISPLAY_STATE,

                                                    

    DEVICE_NOTIFY_CALLBACK,

                                                     &ScreenEventParams,

                                                     &m_RegistrationHandle

                                                     );

    The function is supported from Windows 7 [desktop apps only]. But DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS is supported from windows 8 on wards.

    When application runs on Windows 7 the returned code from the API is INVALID PARAMETER.

    Please suggest the alternative API or Input structure to pass for the function.

    Thanks,

    Prakash Manannavar.

    Tuesday, August 26, 2014 6:58 AM

Answers

  • The docs for PowerSettingRegisterNotification are wrong. DEVICE_NOTIFY_CALLBACK is not a supported Flag for win7.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 26, 2014 7:33 PM

All replies

  • the third parameter is a handle, not a pointer to a struct. if DEVICE_NOTIFY_CALLBACKis specified, I would think a raw function pointer is value for Recipient. perhaps your callback is being invoked immediately at the docs indicate (ie isConnectedStandby is called) and you are returning an error code.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 26, 2014 7:16 AM
  • @ the last in the link mention below, tells that

    if DEVICE_NOTIFY_CALLBACK is specified

    the callback method passed in must have a signature as defined by

    DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS.

    http://msdn.microsoft.com/en-us/library/windows/desktop/hh769082(v=vs.85).aspx


    I have used the RAW function pointer for isConnectedStandby function directly but it didn't work.
    Tuesday, August 26, 2014 7:31 AM
  • nowhere on the MSDN page you reference does it say that DEVICE_NOTIFY_CALLBACK is the structure to pass for Recipient to specify the callback. Only PowerRegisterSuspendResumeNotification function (NOT PowerSettingRegisterNotification) specifies this structure as the way to pass in the callback

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 26, 2014 7:41 AM
  • In link http://msdn.microsoft.com/en-us/library/windows/desktop/hh769082(v=vs.85).aspx

    There is "Community Additions" sections after "See also".

    Please parse till End of the page. There is comment from Jeff Miller.

    With input of DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS structure only I was able to succeed with the API on windows 8.x.

    Thanks,

    Prakash



    Tuesday, August 26, 2014 8:47 AM
  • that comment says the signature must match the one documented for DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS , it does not say that DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS is the parameter.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 26, 2014 6:49 PM
  • The docs for PowerSettingRegisterNotification are wrong. DEVICE_NOTIFY_CALLBACK is not a supported Flag for win7.

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, August 26, 2014 7:33 PM
  • Dear Doron Holan,

    Is there any way to get notification for Screen state(Screen ON/OFF/DIM) change in Windows 7?

    Any other windows API, that can help me to achieve same.

    Thanks,

    Prakash

    Wednesday, August 27, 2014 6:18 AM
  • Hi Prakash,

    I am facing the same problem too & have not been able to find much on this on internet. I am sure, by now you would have resolved this problem.

    Could you please share your solution with us?

    Regards.

    Nitin

    Wednesday, December 17, 2014 9:27 AM
  • Hi Nitin,

    I have tried other methods to achieve the feature but it was failure.

    In my case during monitor screen off my device has to complete all IOCTLs. I achieve this with virtual driver before going for transition.

    ~~

    Prakash

    Thursday, February 5, 2015 9:08 AM