notify.cs
来自「清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码」· CS 代码 · 共 46 行
CS
46 行
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 + =
减小字号Ctrl + -
显示快捷键?