Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need to identify when the user locks up their Windows Operating System user, or the user goes into hibernation, or sleep, and takes action.


What I have tried:

SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(OnPowerModeChanged);


private static void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e)
        {
            switch (e.Mode)
            {
                case PowerModes.Resume:
                    MessageBox.Show("PowerMode: OS is resuming from suspended state");
                    break;

                case PowerModes.Suspend:
                    MessageBox.Show("PowerMode: OS is about to be suspended");
                    break;
            }
        }
Posted
Updated 23-Oct-19 21:27pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900