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;