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

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

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
© 版权声明
THE END
喜欢就支持一下吧
点赞7 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容