有条件地刷新Inno Setup中的外壳关联(仅在选中功能的情况下)

时间:2018-07-13 16:25:54

标签: windows inno-setup pascalscript

正如标题所述,如何使Inno Setup使用:

[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 个答案:

答案 0 :(得分:2)

Fyi,在下一版本中,您将能够编写:

[Setup]
ChangesAssociations=installation

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

感谢这个想法:)

答案 1 :(得分:1)

不是使用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