📄 notify.cs
字号:
using System;
using System.Runtime.InteropServices;
namespace NamedEvents
{
public static class Notify
{
public static void RegisterNamedEvent(NotificationEvent whichEvent, string eventName)
{
NativeMethods.CeRunAppAtEvent(NativeMethods.EventPrefix + eventName, whichEvent);
}
public static void UnregisterNamedEvent(string eventName)
{
NativeMethods.CeRunAppAtEvent(NativeMethods.EventPrefix + eventName, NotificationEvent.None);
}
}
internal static class NativeMethods
{
internal const string EventPrefix = "\\\\.\\Notifications\\NamedEvents\\";
[DllImport("coredll")]
internal static extern bool CeRunAppAtEvent(string pwszAppName, NotificationEvent lWhichEvent);
}
public enum NotificationEvent
{
None = 0,
TimeChange = 1,
SyncEnd = 2,
OnACPower = 3,
OffACPower = 4,
NetConnect = 5,
NetDisconnect = 6,
DeviceChange = 7,
IrDiscovered = 8,
RS232Detected = 9,
RestoreEnd = 10,
Wakeup = 11,
TZChange = 12,
MachineNameChange = 13,
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -