inno setup 指令碼常用修改 轉

來源:互聯網
上載者:User

標籤:

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;

inno setup 指令碼常用修改 轉

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.