示例#1
0
        private void CleanUpOldTrayIconIfAppropriate()
        {
            // If we closed improperly last time, make sure the old tray icon isn't still around.
            try {
                var oldTrayIconID   = LibraryRegistry.GetInt32Value(RegSettingNames.LastTrayID);
                var oldTrayIconHwnd = LibraryRegistry.GetInt32Value(RegSettingNames.LastTrayHwnd);
                if (oldTrayIconID.HasValue && oldTrayIconHwnd.HasValue)
                {
                    try {
                        var oldTrayIconData = new NOTIFYICONDATA();
                        oldTrayIconData.hwnd = new IntPtr(oldTrayIconHwnd.Value);
                        oldTrayIconData.uID  = oldTrayIconID.Value;

                        Shell_NotifyIcon(NIM_DELETE, ref oldTrayIconData);
                    } finally {
                        LibraryRegistry.DeleteValue(RegSettingNames.LastTrayID);
                        LibraryRegistry.DeleteValue(RegSettingNames.LastTrayHwnd);
                    }
                }
            } catch (Exception e) {
                Log.Logger.WarnException("Exception removing last tray icon", e);
            }
        }
示例#2
0
 private void DeleteReferenceToProperlyClosedTrayIcon()
 {
     // we're shutting down properly, so no need to save the last tray icon info
     LibraryRegistry.DeleteValue(RegSettingNames.LastTrayID);
     LibraryRegistry.DeleteValue(RegSettingNames.LastTrayHwnd);
 }