Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup refresh desktop

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

Either by using SendMessage or somehow use SHChangeNotify?


1 Answers

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 '[email protected] 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 did you know that Inno Setup can refresh the desktop for you, automatically? Simply write

ChangesAssociations=yes

in the [Setup] section. See: ChangesAssociations

like image 53
Andreas Rejbrand Avatar answered Sep 22 '25 11:09

Andreas Rejbrand