【问题标题】:Any way to remove notify icon in event of a crash?发生崩溃时有什么方法可以删除通知图标?
【发布时间】:2009-07-20 10:15:20
【问题描述】:

有没有办法在发生崩溃时自动删除 NotifyIcon? (我知道您可以将鼠标悬停以将其删除)

我正在运行 windows xp。

【问题讨论】:

    标签: c# winforms winapi windows-xp


    【解决方案1】:

    对于 C#,尝试处理来自 AppDomain 的 UnhandledException 事件,因此,在您的 Main() 方法中添加:

    AppDomain.CurrentDomain.UnhandledException += 
        new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
    

    然后添加如下方法:

    static void CurrentDomain_UnhandledException(object sender, 
        UnhandledExceptionEventArgs e)
    {
        // .... Remove Notification icon here
    }
    

    【讨论】:

      【解决方案2】:

      不幸的是,答案是否定的 - Rob 的答案实际上检测到崩溃并尝试删除崩溃处理程序中的图标,该处理程序有自己的一组问题(例如,它假设在崩溃时有足够的 CLR 正在运行执行未处理的异常,情况并非总是如此)。

      这里的问题是外壳(运行 Shell_NotifyIcon 代码)与您的应用程序不同步。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-05-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-16
        相关资源
        最近更新 更多