⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notify.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 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 + -