Inno Setup refresh desktop

2019-04-13 08:34发布

问题:

Is it possible to refresh the desktop using Inno Setup in the [Code] section?

Either by using SendMessage or somehow use SHChangeNotify?

回答1:

You can call any function in the Windows API by calling it in the appropriate DLL. The Pascal DLL syntax is documented here. The documentation of the SHChangeNotify function is found at MSDN as usual. This function is found in Shell32.dll (no surprise!).

[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;

Now you can call SendChangeNotification anywhere you like, for instance in an event function.

Update

The text above answers your question, how to "refresh the desktop using Inno Setup in the [Code] section". But you know that Inno Setup can refresh the desktop for you, automatically? Simply write

ChangesAssociations=yes

in the [Setup] section.