管理

修改已完成系统提醒类 - C#小函数类推荐

Posted on 2024-11-02 09:30  lzhdim  阅读(10005)  评论(0编辑  收藏  举报

       此文记录的是修改操作后的系统提醒操作类。

/***

    修改已完成系统提醒类

    Austin Liu 刘恒辉
    Project Manager and Software Designer

    E-Mail: lzhdim@163.com
    Blog:   http://lzhdim.cnblogs.com
    Date:   2024-01-15 15:18:00

    使用方法:
        NotifyUtil.NotifySHChange();

    说明:
        当更改资源管理中的目录图标,然后运行此类代码。

***/

namespace Lzhdim.LPF.Utility
{
    using System;
    using System.Runtime.InteropServices;

    /// <summary>
    /// 系统通知操作类
    /// </summary>
    public class NotifyUtil
    {
        private const uint SHCNE_ASSOCCHANGED = 0x8000000;

        private const uint SHCNF_FLUSH = 0x8000;
        private const uint SHCNF_FLUSHNOWAIT = 0x1000;
        private const int SHCNF_PATH = 0x0005;

        /// <summary>
        /// 通知系统图标已更改
        /// </summary>
        public static void NotifySHChange()
        {
            // 通知系统图标已更改
            SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSHNOWAIT, IntPtr.Zero, IntPtr.Zero);

            SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_PATH, IntPtr.Zero, IntPtr.Zero);
        }

        [DllImport("shell32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);
    }
}

 

Copyright © 2000-2022 Lzhdim Technology Software All Rights Reserved