Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply a skin to Inno Setup uninstaller with the ISSkin library?

Tags:

inno-setup

I know, how to apply a skin with the ISSkin add-on to Inno Setup's installer part, but I can't figure out, how to do the same for the Inno Setup uninstaller.

How can I apply a skin with the ISSkin add-on also to uninstaller ?

like image 357
Andrezork Avatar asked Jan 29 '13 20:01

Andrezork


1 Answers

You will have to extract the ISSkin.dll library along with a skin file into a certain directory and keep it stored, unless your user runs the uninstaller. That's because the uninstaller is an application generated by the setup, and so they're just different (uninstaller e.g. doesn't contain files that could be extracted).

You also need to take into account, that if you'll want to have the whole uninstall process to be skinned, you'll need to unload the ISSkin.dll library at the very end of the uninstallation process and that will require you to remove the library with a skin file manually. For this, I'd strongly recommend you to use a folder different from the application one, to allow the uninstaller properly remove the application and the rest do by yourself. Here's a script example, which uses for this local application data folder:

You can follow the commented version of this code as well.

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program
OutputDir=userdocs:Inno Setup Examples Output

#define SetupSkinPath "{localappdata}\SetupSkin"

[Files]
Source: ISSkinU.dll; DestDir: {#SetupSkinPath}; Flags: uninsneveruninstall
Source: Styles\Office2007.cjstyles; DestDir: {#SetupSkinPath}; Flags: uninsneveruninstall
[Code]
procedure SetupLoadSkin(lpszPath: string; lpszIniFileName: string);
  external 'LoadSkin@files:ISSkinU.dll stdcall setuponly';
procedure SetupUnloadSkin;
  external 'UnloadSkin@files:ISSkinU.dll stdcall setuponly';
procedure UninstLoadSkin(lpszPath: string; lpszIniFileName: string);
  external 'LoadSkin@{#SetupSkinPath}\ISSkinU.dll stdcall uninstallonly';
procedure UninstUnloadSkin;
  external 'UnloadSkin@{#SetupSkinPath}\ISSkinU.dll stdcall uninstallonly';
function ShowWindow(hWnd: HWND; nCmdShow: Integer): BOOL;
  external '[email protected] stdcall';

function InitializeSetup: Boolean;
begin
  Result := True;
  ExtractTemporaryFile('Office2007.cjstyles');
  SetupLoadSkin(ExpandConstant('{tmp}\Office2007.cjstyles'), 'NormalBlack.ini');    
end;

procedure DeinitializeSetup;
begin
  ShowWindow(StrToInt(ExpandConstant('{wizardhwnd}')), SW_HIDE);
  SetupUnloadSkin;
end;

function InitializeUninstall: Boolean;
begin
  Result := True;
  UninstLoadSkin(ExpandConstant('{#SetupSkinPath}\Office2007.cjstyles'), 
    'NormalBlack.ini');  
end;

procedure DeinitializeUninstall;
begin
  UninstUnloadSkin;
  UnloadDLL(ExpandConstant('{#SetupSkinPath}\ISSkinU.dll'));
  DeleteFile(ExpandConstant('{#SetupSkinPath}\ISSkinU.dll'));
  DeleteFile(ExpandConstant('{#SetupSkinPath}\Office2007.cjstyles'));
  RemoveDir(ExpandConstant('{#SetupSkinPath}'));
end;
like image 176
TLama Avatar answered Nov 14 '22 12:11

TLama