最新消息:

NSIS 强制结束程序移除托盘图标

nsis 永恒心锁 1950浏览 0评论

方案一、
强制结束有托盘图标的进程时,需要把鼠标移到托盘图标时,图标才会消失
想图标立即消失,用以下代码即可:

FindWindow $0 "Shell_TrayWnd"
FindWindow $0 "TrayNotifyWnd" "" $0
FindWindow $1 "ToolBarWindow32" "" $0 ;Win2K
StrCmp $1 0 0 +3
FindWindow $0 "SysPager" "" $0
FindWindow $1 "ToolBarWindow32" "" $0 ;WinXP/2003
SendMessage $1 ${WM_MOUSEMOVE} 0 0

——————————————————————————–

方案二、
用 Shell_NotifyIcon 需要用 System 插件

例子:

!include "UsefulLib.nsh"
!define NIM_DELETE 2

!insertmacro DEFINE_FUNC_LITE DelTrayIcon
!macro INSERT_FUNC_LITE_DelTrayIcon HWND uID
Push $1
System::Call "*(i 88, i ${HWND}, i ${uID}, i, i, i, &t64) i .r1"
System::Call "Shell32::Shell_NotifyIcon(i, i) i (${NIM_DELETE}, r1)"
System::Free $1
Pop $1
!macroend

Section
FindWindow $0 "Afx:400000:0" "Lingoes 灵格斯"
;${DelTrayIcon} $0 128 ;发送{WM_CLOSE}可以结束进程就不需要了
SendMessage $0 ${WM_CLOSE} 0 0

FindWindow $0 "Eset Client Frame" "ESET NOD32 Antivirus"
${DelTrayIcon} $0 0 ;发送{WM_CLOSE}不能结束进程就要先删掉图标
KillProcDLL::KillProc "egui.exe" ;强制结束进程
SectionEnd
永恒心锁,版权所有丨如未注明,均为转载丨本网站采用BY-NC-SA协议进行授权

转载请注明:永恒心锁-分享互联网 » NSIS 强制结束程序移除托盘图标

您必须 登录 才能发表评论!