示例#1
0
        private static void InvokerProc(PowerStateFlags state)
        {
            DeviceNotification notification = null;

            switch (state)
            {
            case PowerStateFlags.On:
                notification = PowerUp;
                break;

            case PowerStateFlags.Suspend:
                notification = PowerDown;
                break;

            case PowerStateFlags.Boot:
                notification = Boot;
                break;

            case PowerStateFlags.CriticalOff:
                notification = PowerCritical;
                break;

            case PowerStateFlags.Idle:
                notification = PowerIdle;
                break;

            default:
                break;
            }

            // if we've got an event handler wired, signal it
            if (notification != null)
            {
                foreach (DeviceNotification dn in notification.GetInvocationList())
                {
                    dn();
                }
            }
        }
示例#2
0
 internal static extern int SetSystemPowerState(string psState, PowerStateFlags flags, uint Options);
示例#3
0
 internal static extern int SetSystemPowerState(IntPtr psState, PowerStateFlags flags, uint Options);