Skip to content

Can Application register when PC goes into sleep/hibernate mode or when it resumes #2630

Answered by castorix
byrialsen asked this question in General
Discussion options

You must be logged in to vote

On my PC, I get 0x0004 then 0x0007, 0x0012

Maybe you can register notifications, for example with PowerRegisterSuspendResumeNotification

A quick test :

            DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS dnsp = new DEVICE_NOTIFY_SUBSCRIBE_PARAMETERS();
            dnsp.Callback = new DEVICE_NOTIFY_CALLBACK_ROUTINE(DeviceNotifyCallbackRoutine);

            IntPtr pDeviceNotify = Marshal.AllocHGlobal(Marshal.SizeOf(dnsp));
            Marshal.StructureToPtr(dnsp, pDeviceNotify, false);
            IntPtr pRegistrationHandle = IntPtr.Zero;
            uint nRet = PowerRegisterSuspendResumeNotification(DEVICE_NOTIFY_CALLBACK, pDeviceNotify, out pRegistrationHandle);
            Marshal.FreeHGlob…

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@byrialsen
Comment options

Comment options

You must be logged in to vote
1 reply
@byrialsen
Comment options

Comment options

You must be logged in to vote
1 reply
@byrialsen
Comment options

Answer selected by byrialsen
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants