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(); } } }
internal static extern int SetSystemPowerState(string psState, PowerStateFlags flags, uint Options);
internal static extern int SetSystemPowerState(IntPtr psState, PowerStateFlags flags, uint Options);