What does PBT_POWERSETTINGSCHANGE (32787) with lParam = 206730400 mean?

103 views Asked by At

I am using trying to track when the monitor goes off due to user inactivity.

To do that, I process PBT_POWERSETTINGCHANGE like this:

    Select Case wParam
        Case PBT_APMPOWERSTATUSCHANGE
            'DebugPrint "PBT_APMPOWERSTATUSCHANGE"
        Case PBT_APMRESUMEAUTOMATIC
           ' DebugPrint "PBT_APMRESUMEAUTOMATIC"
        Case PBT_APMRESUMESUSPEND
            'DebugPrint "PBT_APMRESUMESUSPEND"
        Case PBT_APMSUSPEND
            'DebugPrint "PBT_APMSUSPEND"
        Case PBT_POWERSETTINGCHANGE
            CopyMemory pbs, ByVal lParam, Len(pbs)
            'DebugPrint "PBT_POWERSETTINGCHANGE " & GuidToString(pbs.PowerSetting)
            Select Case GuidToString(pbs.PowerSetting)
                Case GUID_POWERSCHEME_PERSONALITY
                    CopyMemory g, ByVal lParam + Len(pbs), 16
                    'DebugPrint "New power scheme: " & GuidToString(g)
                Case GUID_SESSION_DISPLAY_STATUS
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Display status: " & L
                Case GUID_MONITOR_POWER_ON
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Primary Monitor state: " & L & " ON!!!"
                Case GUID_CONSOLE_DISPLAY_STATE
                    CopyMemory l, ByVal lParam + Len(pbs), 4
                    'DebugPrint "Console Display state: " & L
            End Select

            If l = 0 Then
                  Debug.Assert False'monitor went off

To my surprise, I experience "GUID_POWERSCHEME_PERSONALITY" and "l = 0" me even though I am just starting my app.

Where do I go wrong, or what should I track in order to be notified when the screen goes off due to inactivity?

0

There are 0 answers