代码之家  ›  专栏  ›  技术社区  ›  Joshua

有条件地刷新inno setup中的shell关联(仅当选中函数时)

  •  1
  • Joshua  · 技术社区  · 6 年前

    如标题所示,我如何使Inno设置使用:

    [Setup]
    ChangesAssociations=yes 
    

    仅当选中某个功能时:

    function installation: Boolean;
    begin
      Result := install.Checked; { only if this is checked }
    end;
    
    function portable: Boolean;
    begin
      Result := porta.Checked;
    end;
    

    当我只提取我的软件的可移植版本时,我需要这个关联不会被调用。

    2 回复  |  直到 6 年前
        1
  •  1
  •   Martin Prikryl    5 年前

    而不是使用 ChangesAssociations 指令,调用 SHChangeNotify WinAPI function 有条件地 CurStepChanged(ssPostInstall) 以下内容:

    [Code]
    
    const
      SHCNE_ASSOCCHANGED = $08000000;
      SHCNF_IDLIST = $00000000;
    
    procedure SHChangeNotify(wEventID: Integer; uFlags: Cardinal; dwItem1, dwItem2: Cardinal);
      external 'SHChangeNotify@shell32.dll stdcall';
    
    procedure CurStepChanged(CurStep: TSetupStep);
    begin
      if CurStep = ssPostInstall then
      begin
        if installation then
        begin
          SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
        end;
      end;
    end;
    

    这就是 ChangesAssociations=yes 内部有。


    部分基于: Inno Setup refresh desktop .

        2
  •  2
  •   mlaan    6 年前

    仅供参考,在下一版本中,您将能够编写:

    [Setup]
    ChangesAssociations=installation
    
    [Code]
    function installation: Boolean;
    begin
      Result := install.Checked; { only if this is checked }
    end;
    

    谢谢你的建议:)