简体   繁体   English

Inno Setup如何在任务栏菜单中隐藏“pin”命令

[英]How Inno Setup hides “pin” command in the Taskbar menu

When and after I build an .exe via Inno Setup, I run the .exe and when I right click the taskbar button of my application, I can only see there an item "Close window". 当我通过Inno Setup构建.exe时,我运行.exe,当我右键单击我的应用程序的任务栏按钮时,我只能看到一个项目“关闭窗口”。 When I build an exe via Visual Studio or any other program in Windows actually, when I click the right click of the mouse, I can see there 3 items. 当我通过Visual Studio或Windows中的任何其他程序构建exe时,当我单击鼠标右键时,我可以看到有3个项目。

  1. Name of the my app. 我的应用程序的名称。
  2. Pin this program to a taskbar. 将此程序固定到任务栏。
  3. Close window. 关闭窗口。

My question is how Inno Setup does that, how can I achieve it programmatically? 我的问题是Inno Setup如何做到这一点,我如何以编程方式实现它?

From: 从:
How do I prevent users from pinning my program to the taskbar? 如何阻止用户将我的程序固定到任务栏?
https://blogs.msdn.microsoft.com/oldnewthing/20110601-00/?p=10523 https://blogs.msdn.microsoft.com/oldnewthing/20110601-00/?p=10523

Use System.AppUserModel.PreventPinning directly in the program: 直接在程序中使用System.AppUserModel.PreventPinning

#include <Windows.h>
#include <shellapi.h>
#include <propsys.h>
#include <propkey.h>

HRESULT MarkWindowAsUnpinnable(HWND hwnd)
{
    IPropertyStore *pps;
    HRESULT hr = SHGetPropertyStoreForWindow(hwnd, IID_PPV_ARGS(&pps));
    if(SUCCEEDED(hr)) 
    {
        PROPVARIANT var;
        var.vt = VT_BOOL;
        var.boolVal = VARIANT_TRUE;
        hr = pps->SetValue(PKEY_AppUserModel_PreventPinning, var);
        pps->Release();
    }
    return hr;
}

...
case WM_CREATE:
    MarkWindowAsUnpinnable(hwnd);
    ...

It's probably related to how the installer is executed. 这可能与安装程序的执行方式有关。

The Inno Setup-made mysetup.exe is (by default) just a loader, that extracts an internal installer to a temporary folder and runs the internal installer elevated. Inno Setup-made mysetup.exe (默认情况下)只是一个加载器,它将内部安装程序提取到临时文件夹并运行内部安装程序。

Windows probably somehow heuristically decides that it does not make any sense pinning an application executed this way from a temporary folder. Windows可能以某种方式启发式地决定从一个临时文件夹固定一个以这种方式执行的应用程序是没有任何意义的。 So it hides the option. 所以它隐藏了选项。

Note that if you disable the loader in Inno Setup, the "pin" command appears. 请注意,如果在Inno Setup中禁用加载程序,则会出现“pin”命令。

[Setup]
UseSetupLdr=no

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM