http://blog.sina.com.cn/s/blog_72c2eb350100y2sa.html
有人提及想更换安装界面的图片,其实方法很简单,只需要修改inno setup安装目录下的WizModernImage.bmp和WizModernSmallImage.bmp两张图片就可以了。
只需在代码页,添加如下代码,即可实现页面的优化。
#define MyAppName "服务端"
#define MyAppVersion "1.3.2"
#define MyAppPublisher "ga526"
[Setup]
AppId={{59FB74DA-DBE1-41EF-B69A-31BE8324D98B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
DefaultDirName=c:\ga526\ga526\服务端
DisableDirPage=yes
DefaultGroupName=ga526服务端
DisableProgramGroupPage=yes
OutputDir=C:\Documents and Settings\Administrator\
OutputBaseFilename=server
SetupIconFile=D:\桌面\图标\ga526.ico
Compression=lzma
SolidCompression=yes
[Files]
//flags 不能少BeforeInstall: ChangeDisplay,这里是调用changedisplay
Source: "C:\Documents and Settings\Administrator\desktop\ga5262011121\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs; BeforeInstall: ChangeDisplay
[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\服务端.exe"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" //在“开始”--“程序”里,添加一个卸载的快捷方式Name: "C:\Documents and Settings\Administrator\「开始」菜单\程序\启动\程序"; Filename: "c:\我的程序.exe" //这里为添加开机启动项,当然也可以通过修改注册表达到这个目的
Name: "C:\Documents and Settings\Administrator\桌面\服务端"; Filename: "{app}\服务端.exe"; //这里是添加桌面快捷方式
[run]
Filename: "{app}\服务端.exe"; flags:"nowait" //安装完成后,立即运行“服务端.exe”
[Code]
var
DetailList: TNewListBox;
newFileNameLabel: TNewStaticText;
LastDir: string;
procedure InitializeWizard();
begin
//界面修改
WizardForm.WizardSmallBitmapImage.left:=426;
WizardForm.taskslist.color:=clWindow;
WizardForm.innerpage.color:=clWindow;
WizardForm.readymemo.color:=clWindow;
WizardForm.PAGENAMELABEL.Font.Color:= clGreen;
WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clGreen;
WizardForm.WelcomeLabel2.Caption := ‘安装向导将在你的电脑上安装 {#MyAppName} ‘ + #13#10 +
+ #13#10 +
‘建议你在继续之前关闭所有其它应用程序。‘ + #13#10 +
‘‘ + #13#10 +
‘单击“下一步”继续,或单击“取消”退‘;
WizardForm.WELCOMELABEL1.Font.Color:= clGreen;
WizardForm.WELCOMELABEL1.top:= 31;
//WizardForm.WELCOMELABEL2.caption:=‘ 请确认你所使用的为我司产品,否则,因软件与硬件‘
//+ #13#10 + + #13#10 + ‘不兼容造成任何问题,本公司不负任何法律责任。‘
//+ #13#10 + + #13#10 + ‘ 建议你在继续安装之前,关闭杀毒软件,并把软件安‘
//+ #13#10 + + #13#10 + ‘装在C盘下‘+‘ 单击“下一步”继续安装本程序,单击“取‘
//+ #13#10 + + #13#10 + ‘消”退出安装。‘ ;
WizardForm.WELCOMELABEL2.top:= 91;
WizardForm.Color:= clwindow;
WizardForm.Bevel1.Left:=0;
WizardForm.Bevel1.top:=0;
WizardForm.Bevel1.width:=0;
WizardForm.Bevel.Left:=0;
WizardForm.Bevel.top:=0;
WizardForm.selectdirbitmapimage.visible:=false;
WizardForm.selectgroupbitmapimage.visible:=false;
WizardForm.selectdirlabel.left:=0;
WizardForm.selectstartmenufolderlabel.left:=0;
WizardForm.Bevel.width:=0;
WizardForm.PageDescriptionLabel.Top:=40;
//页面修改完毕
//显示细节
DetailList:= TNewListBox.Create(WizardForm);
DetailList.Parent := WizardForm.InstallingPage;
DetailList.Left := ScaleX(0);
DetailList.Top := ScaleY(70);
DetailList.Width := ScaleX(417);
DetailList.Height := ScaleY(153);
newFileNameLabel:= TNewStaticText.Create(WizardForm) // 创建 FileNameLabel 的替代
newFileNameLabel.Parent := WizardForm.InstallingPage;
newFileNameLabel.Top := WizardForm.FileNameLabel.Top;
newFileNameLabel.Left := WizardForm.FileNameLabel.Left;
newFileNameLabel.Width := WizardForm.FileNameLabel.Width;
WizardForm.FileNameLabel.Visible := false; // 隐藏本来的 FileNameLabel
LastDir:= ‘‘;
end;
procedure ChangeDisplay;
var
dn, fn: string;
pct: Extended;
begin
pct := (WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min)/(WizardForm.ProgressGauge.Max-WizardForm.ProgressGauge.Min)*100;
dn:= ExpandConstant(ExtractFileDir(CurrentFileName));
fn:= ExtractFileName(CurrentFileName);
WizardForm.StatusLabel.Caption:= ‘输出目录: ‘ + dn;
newFileNameLabel.Caption:= ‘抽取: ‘ + fn + ‘ (‘ + IntToStr(Round(pct)) + ‘% 已完成)‘;
if dn <> LastDir then
begin
DetailList.Items.Append(‘输出目录: ‘ + dn);
LastDir:= dn;
end;
DetailList.Items.Append(‘抽取: ‘ + fn + ‘ (‘ + IntToStr(Round(pct)) + ‘% 已完成)‘);
DetailList.ItemIndex := DetailList.Items.Count - 1;
end;
//显示细节完毕
////修改卸载文件
procedure CurStepChanged(CurStep: TSetupStep);
var
uninspath, uninsname, NewUninsName, MyAppName: string;
begin
if CurStep=ssDone then
begin
// 指定新的卸载文件名(不包含扩展名),请相应修改!
NewUninsName := ‘卸载服务端‘;
// 应用程序名称,与 [SEUTP] 段的 AppName 必须一致,请相应修改!
MyAppName := ‘服务端‘;
// 以下重命名卸载文件
uninspath:= ExtractFilePath(ExpandConstant(‘{uninstallexe}‘));
uninsname:= Copy(ExtractFileName(ExpandConstant(‘{uninstallexe}‘)),1,8);
RenameFile(uninspath + uninsname + ‘.exe‘, uninspath + NewUninsName + ‘.exe‘);
RenameFile(uninspath + uninsname + ‘.dat‘, uninspath + NewUninsName + ‘.dat‘);
// 以下修改相应的注册表内容
if RegKeyExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\‘ + MyAppName + ‘_is1‘) then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\‘ + MyAppName + ‘_is1‘, ‘UninstallString‘, ‘"‘ + uninspath + NewUninsName + ‘.exe"‘);
RegWriteStringValue(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\‘ + MyAppName + ‘_is1‘, ‘QuietUninstallString‘, ‘"‘ + uninspath + NewUninsName + ‘.exe" /SILENT‘);
end;
end;
end;