如何使用ISSkin库将皮肤应用于Inno Setup卸载程序?

时间:2013-01-29 20:14:26

标签: inno-setup

我知道,如何将ISSkin add-on的皮肤应用到Inno Setup的安装程序部分,但我无法弄清楚,如何为Inno Setup卸载程序执行相同操作。

如何将ISSkin add-on的皮肤也应用于卸载程序?

1 个答案:

答案 0 :(得分:7)

除非用户运行卸载程序,否则您必须将ISSkin.dll库以及外观文件解压缩到某个目录并保存。这是因为卸载程序是由安装程序生成的应用程序,因此它们只是不同(卸载程序,例如不包含可以提取的文件)。

您还需要考虑,如果您希望将整个卸载过程设置为皮肤,则需要在卸载过程的最后卸载ISSkin.dll库并且将要求您手动删除带有皮肤文件的库。为此,我强烈建议您使用与应用程序不同的文件夹,以允许卸载程序正确删除应用程序,其余部分由您自己执行。这是一个脚本示例,用于此本地应用程序数据文件夹:

您也可以关注the commented version of this code

[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 'ShowWindow@user32.dll 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;