nsis - 在卸载时从任务栏中删除固定图标
nsis - remove pinned icon from taskbar on uninstall
我正在为一家公司开发应用程序,他们要求如果应用程序固定到任务栏,则在卸载应用程序时应取消固定。如果我只是从 quicklaunch\user pinned\taskbar 中删除图标,那么它会在任务栏上留下一个空白图标。
我需要以某种方式取消固定它。我遇到的唯一一件事是安装 winshell 插件 (http://nsis.sourceforge.net/WinShell_plug-in) and then calling IStartMenuPinnedList::RemoveFromList (https://msdn.microsoft.com/en-us/library/windows/desktop/bb774817(v=vs.85).aspx)
如果不需要,我宁愿不安装插件。有人有什么建议吗?
NSIS 本机不支持此接口,因此您必须使用插件。如果你想避免那个第 3 方插件(由我编写),那么你可以改用系统插件:
!include "LogicLib.nsh"
!include "Win\COM.nsh" ; NSIS v3+
!macro UnpinShortcut lnkpath
Push [=10=]
Push
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 ""
${If} [=10=] P<> 0
System::Call 'SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' "${lnkpath}"
${If} P<> 0
${IStartMenuPinnedList::RemoveFromList} [=10=] '(r1)'
${IUnknown::Release} ""
${EndIf}
${IUnknown::Release} [=10=] ""
${EndIf}
Pop
Pop [=10=]
!macroend
Section Uninstall
!insertmacro UnpinShortcut "$SMPrograms\MyApp.lnk"
Delete "$SMPrograms\MyApp.lnk"
SectionEnd
我正在为一家公司开发应用程序,他们要求如果应用程序固定到任务栏,则在卸载应用程序时应取消固定。如果我只是从 quicklaunch\user pinned\taskbar 中删除图标,那么它会在任务栏上留下一个空白图标。
我需要以某种方式取消固定它。我遇到的唯一一件事是安装 winshell 插件 (http://nsis.sourceforge.net/WinShell_plug-in) and then calling IStartMenuPinnedList::RemoveFromList (https://msdn.microsoft.com/en-us/library/windows/desktop/bb774817(v=vs.85).aspx)
如果不需要,我宁愿不安装插件。有人有什么建议吗?
NSIS 本机不支持此接口,因此您必须使用插件。如果你想避免那个第 3 方插件(由我编写),那么你可以改用系统插件:
!include "LogicLib.nsh"
!include "Win\COM.nsh" ; NSIS v3+
!macro UnpinShortcut lnkpath
Push [=10=]
Push
!insertmacro ComHlpr_CreateInProcInstance ${CLSID_StartMenuPin} ${IID_IStartMenuPinnedList} r0 ""
${If} [=10=] P<> 0
System::Call 'SHELL32::SHCreateItemFromParsingName(ws, p0, g "${IID_IShellItem}", *p0r1)' "${lnkpath}"
${If} P<> 0
${IStartMenuPinnedList::RemoveFromList} [=10=] '(r1)'
${IUnknown::Release} ""
${EndIf}
${IUnknown::Release} [=10=] ""
${EndIf}
Pop
Pop [=10=]
!macroend
Section Uninstall
!insertmacro UnpinShortcut "$SMPrograms\MyApp.lnk"
Delete "$SMPrograms\MyApp.lnk"
SectionEnd