Inno Setup刷新桌面

4 windows inno-setup pascalscript

是否可以使用本节中的 Inno Setup 刷新桌面[Code]

通过使用SendMessage或以某种方式使用SHChangeNotify

And*_*and 5

您可以通过在适当的 DLL 中调用 Windows API 中的任何函数来调用它。Pascal DLL 语法记录在此处。像往常一样,该SHChangeNotify函数的文档可以在 MSDN 上找到。这个函数可以在(毫不奇怪!)中找到Shell32.dll

[Code]
const
  SHCNE_ASSOCCHANGED = $08000000;
  SHCNF_IDLIST = $00000000;

procedure SHChangeNotify(wEventID: integer; uFlags: cardinal; dwItem1, dwItem2: cardinal);
external 'SHChangeNotify@shell32.dll stdcall';

procedure SendChangeNotification;
begin
  SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0);
end;
Run Code Online (Sandbox Code Playgroud)

现在您可以SendChangeNotification在任何您喜欢的地方调用,例如在事件函数中。

更新

上面的文字回答了您的问题,如何“使用本[Code]节中的 Inno Setup 刷新桌面”。但您知道 Inno Setup 可以自动为您刷新桌面吗?简单地写

ChangesAssociations=yes
Run Code Online (Sandbox Code Playgroud)

在该[Setup]部分中。看:ChangesAssociations