INNO SETUP 配置

添加到啓動

 

[Registry]

Root: HKLM; Subkey: SOFTWARE/Microsoft/Windows/CurrentVersion/Run; ValueType: string; ValueName: 開機啓動; ValueData: """C:/Program Files/Thunder/Thunder.exe"" /s"; Flags: uninsdeletevalue


1 、如何讓協議許可頁面默認選中我同意按鈕 
[code]
procedure InitializeWizard();
begin
WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;
2、自定義安裝程序右上角圖片大小 
[code]
procedure InitializeWizard();
begin
WizardForm.WizardSmallBitmapImage.width:=150; //設置頁眉圖片的大小
WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //設置左邊頁眉留出的空隙
WizardForm.PAGENAMELABEL.width:=0; //設置標題文字顯示的大小
WizardForm.PAGEDESCRIPTIONLABEL.width:=0; //設置標題文字顯示的大小
end;
或者
//自定義安裝嚮導小圖片 
[code]
procedure InitializeWizard();
begin
Wizardform.WizardSmallBitmapImage.left:= WizardForm.width-164; //自定義安裝嚮導小圖片顯示位置
WizardForm.WizardSmallBitmapImage.width:=164; //自定義安裝嚮導小圖片寬度
Wizardform.PageNameLabel.width:= 495 - 164 -36; //這兒必須定義,數值根據圖片寬度更改,顯示軟件名稱的位置
Wizardform.PageDescriptionLabel.width:= 495 - 164 -42; //顯示頁面信息的位置
end;
3、自定義BeveledLabel顯示代碼 
[code]
procedure InitializeWizard();
begin
WizardForm.BeveledLabel.Enabled:=true; //允許顯示
WizardForm.BeveledLabel.Font.Color:=$00058451;; //顯示顏色
WizardForm.BeveledLabel.Font.Style := WizardForm.BeveledLabel.Font.Style + [fsBold]; //顯示字體
WizardForm.BeveledLabel.Left:=5; //顯示位置
end;
4、自定義安裝嚮導圖片 
[code]
procedure InitializeWizard();
begin
Wizardform.WELCOMELABEL1.left:= 18; //自定義歡迎頁面標題1顯示位置
Wizardform.WELCOMELABEL2.left:= 18; //自定義歡迎頁面標題2顯示位置
Wizardform.WizardBitmapImage.left:= WizardForm.width-164 //自定義安裝嚮導圖片顯示位置(顯示大小,此處爲居右顯示)
end;
5、顯示出組件選擇框 
[Types]
Name: full; Description: 推薦
Name: default; Description: 典型
Name: custom; Description: 自定義; Flags: iscustom
;告訴安裝程序這個類型是自定義類型。必須定義iscustom這個參數,才能顯示出組件選擇框
6、定義[Messages]的顏色 
[code]
procedure InitializeWizard();
begin
WizardForm.BeveledLabel.Enabled:= True;
WizardForm.BeveledLabel.Font.Color:= clblue;
end;
7、不顯示一些特定的安裝界面 
[code]
function ShouldSkipPage(PageID: Integer): Boolean; 
begin 
if PageID=wpReady then 
result := true; 
end;
wpReady  是準備安裝界面
PageID查詢 INNO幫助中的 Pascal 腳本: 事件函數常量
預定義嚮導頁 CurPageID 值
wpWelcome, wpLicense, wpPassword, wpInfoBefore, wpUserInfo, wpSelectDir, wpSelectComponents, wpSelectProgramGroup, wpSelectTasks, wpReady, wpPreparing, wpInstalling, wpInfoAfter, wpFinished
8、換行符號
在  [Messages]   換行符號爲%n
在  MsgBox  中換行符號爲 #13#10    //#13 爲回車字符
9、顏色代碼
(1)一個值形如 $bbggrr, 這裏的 rr, gg 和 bb 指定了兩位的亮度值(以十六進制表示)分別爲紅色,綠色和藍色。
(2)預定義的顏色名稱:
clBlack(黑色),clMaroon(暗紅),clGreen(綠色),clOlive(橄欖綠),
clNavy(深藍),clPurple(紫色),clTeal(深青),clGray(灰色),
clSilver(淺灰),clRed(紅色),clLime(淺綠),clYellow(黃色),
clBlue(藍色),clFuchsia(紫紅),clAqua(青綠),clWhite(白色)。
10、inno代碼註釋符號
;      實例 ——   ; 分號 
//     實例 ——  // 雙斜槓  多用在code段
{ }    實例 —— {大括號    多用在code段}
註釋符號均在英文輸入法狀態下輸入
11、在運行卸載程序前顯示彈出式消息 
[code]
function InitializeUninstall(): Boolean;
begin
if MsgBox('', mbConfirmation, MB_YESNO) = IDYES then
result:=true
else
result:=false;
end;
12、安裝、卸載時判斷是否程序正在運行,卸載完成時自動打開網頁 
[code]
var
  ErrorCode: Integer;
  IsRunning: Integer;
// 安裝時判斷客戶端是否正在運行   
function InitializeSetup(): Boolean;   
begin   
  Result :=true;  //安裝程序繼續   
  IsRunning:=FindWindowByWindowName('東方寬頻網絡電視');   
  while IsRunning<>0 do  
  begin   
    if Msgbox('安裝程序檢測到客戶端正在運行。'  #13#13 '您必須先關閉它然後單擊“是”繼續安裝,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    begin   
      Result :=false; //安裝程序退出   
      IsRunning :=0;   
    end else begin   
      Result :=true;  //安裝程序繼續   
      IsRunning:=FindWindowByWindowName('東方寬頻網絡電視');   
    end;   
  end;   
end;   
// 卸載時判斷客戶端是否正在運行   
function InitializeUninstall(): Boolean;   
begin   
   Result :=true;  //安裝程序繼續   
  IsRunning:=FindWindowByWindowName('東方寬頻網絡電視');   
  while IsRunning<>0 do  
  begin   
  
    if Msgbox('安裝程序檢測到客戶端正在運行。'  #13#13 '您必須先關閉它然後單擊“是”繼續安裝,或按“否”退出!', mbConfirmation, MB_YESNO) = idNO then   
    begin   
      Result :=false; //安裝程序退出   
      IsRunning :=0;   
    end else begin   
      Result :=true;  //安裝程序繼續   
      IsRunning:=FindWindowByWindowName('東方寬頻網絡電視');     
    end;   
  end;   
end;   
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);   
begin   
  case CurUninstallStep of   
    usUninstall:     
      begin // 開始卸載   
      end;   
    usPostUninstall:   
      begin      // 卸載完成   
        // MsgBox('CurUninstallStepChanged:' #13#13 'Uninstall just finished.', mbInformation, MB_OK);   
        // ...insert code to perform post-uninstall tasks here...   
        ShellExec('open', 'http://www.dreams8.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);   
      end;   
  end;   
end;   
13、 刪除文件和刪除文件夾 
//刪除文件    用 DeleteFile 只能刪除一個文件,不能使用通配符來刪除多個文件
DeleteFile(ExpandConstant('{app}/abc.exe'));
//刪除所有文件及文件夾
DelTree(ExpandConstant('{app}'), True, True, False);
14、BorderStyle
TFormBorderStyle = (bsNone, bsSingle, bsSizeable, bsDialog, bsToolWindow, bsSizeToolWin);
無邊界式(bsNone)  ,單邊固定式(bsSingle),雙邊可變式(bsSizeable),對話框式(bsDialog)
15、if   else
function NextButtonClick(CurPageID: Integer): Boolean; 
var 
  ResultCode: Integer; 
begin 
  Result := True; 
  if (CurPageID = wpSelectDir) then 
  begin 
  MsgBox('AAAA', mbInformation, MB_OK); 
  end 
  else 
  begin 
  MsgBox('BBBB', mbInformation, MB_OK); 
  end; 
end;
16、安裝結束界面增加“設爲首頁”選項
[Tasks]
Name: changestartpage; Description: "設置vistaqq爲默認主頁"
[Registry]
Root: HKCU; Subkey: "Software/Microsoft/Internet Explorer/Main"; ValueType: string; ValueName: "Start Page"; ValueData: "http://www.vistaqq.com"; tasks: changestartpage
 17、添加“關於”和網站鏈接按鈕
[Code]
procedure URLLabelOnClick(Sender: TObject);
var
  ErrorCode: Integer;
begin
  ShellExec('open', 'http://www.vistaqq.com', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode);
end;
procedure AboutButtonOnClick(Sender: TObject);
begin
  MsgBox(#13 'Vista 狀態條風格盤符' #13 #13'本軟件由jinn製作,希望各位登陸中天VIP工作室!' #13#13 '版權所有 (C)  中天VIP工作室', mbInformation, MB_OK);
end;
var
    AboutButton, CancelButton: TButton;
    URLLabel: TNewStaticText;
procedure InitializeWizard();
begin
  { Create the pages }
WizardForm.PAGENAMELABEL.Font.Color:= clred;
WizardForm.PAGEDESCRIPTIONLABEL.Font.Color:= clBlue;
WizardForm.WELCOMELABEL1.Font.Color:= clGreen;
WizardForm.WELCOMELABEL2.Font.Color:= clblack;
   CancelButton := WizardForm.CancelButton;
     AboutButton := TButton.Create(WizardForm);
     AboutButton.Left := WizardForm.ClientWidth - CancelButton.Left - CancelButton.Width;
     AboutButton.Top := CancelButton.Top;
     AboutButton.Width := CancelButton.Width;
     AboutButton.Height := CancelButton.Height;
     AboutButton.Caption := '&About';
     AboutButton.OnClick := @AboutButtonOnClick;
     AboutButton.Parent := WizardForm;
  URLLabel := TNewStaticText.Create(WizardForm);
    URLLabel.Caption := '中天VIP工作室';
    URLLabel.Cursor := crHand;
    URLLabel.OnClick := @URLLabelOnClick;
    URLLabel.Parent := WizardForm;
    { Alter Font *after* setting Parent so the correct defaults are inherited first }
    URLLabel.Font.Style := URLLabel.Font.Style + [fsUnderline];
    URLLabel.Font.Color := clBlue;
    URLLabel.Top := AboutButton.Top + AboutButton.Height - URLLabel.Height - 2;
    URLLabel.Left := AboutButton.Left + AboutButton.Width + ScaleX(20);
end;
18、去掉安裝程序左上角“關於安裝程序”的代碼
procedure InitializeWizard();
begin
WizardForm.BorderIcons:= [biMinimize];
end;
procedure CurPageChanged(CurPage: Integer);
begin
if CurPage=wpWelcome then
WizardForm.BorderIcons:= [biSystemMenu, biMinimize];
end;
或者
procedure InitializeWizard();
begin
WizardForm.BORDERICONS := [biHelp, biSystemMenu, biMinimize];
end;
19、自定義BeveledLabel文字
[Messages]
BeveledLabel=中天VIP工作室
20、自定義安裝程序界面左上角“安裝”文字
[message]
SetupAppTitle=需要的字
SetupWindowTitle=需要的字
21、自定義安裝程序版本號
VersionInfoVersion=1.1
VersionInfoTextVersion=1.1

發佈了28 篇原創文章 · 獲贊 4 · 訪問量 17萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章