我正在使用这些系统通知来检测Windows的电源关闭或开机事件。现在我试图延迟断电事件并在此之前执行一个功能那么这怎么可能。
[DllImport(@"User32", EntryPoint = "RegisterPowerSettingNotification",
CallingConvention = CallingConvention.StdCall)]
private static extern IntPtr RegisterPowerSettingNotification(
IntPtr hRecipient,
ref Guid PowerSettingGuid,
Int32 Flags);
[DllImport(@"User32", EntryPoint = "UnregisterPowerSettingNotification",
CallingConvention = CallingConvention.StdCall)]
private static extern bool UnregisterPowerSettingNotification(
IntPtr handle);