InnoSetup 打包代碼 檢測.netFramework


 InnoSutup打包工具下載

 

不帶.netFramework

 

View Code
 1 ; 腳本用 Inno Setup 腳本向導 生成。
 2 ; 查閱文檔獲取創建 INNO SETUP 腳本文件詳細資料!
 3 
 4 [Setup]
 5 ; 注意: AppId 的值是唯一識別這個程序的標志。
 6 ; 不要在其他程序中使用相同的 AppId 值。
 7 ; (在編譯器中點擊菜單“工具 -> 產生 GUID”可以產生一個新的 GUID)
 8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
 9 AppName=xxxxxxxxxxxxxxxx V1.1.8.8
10 AppVerName=xxxxxxxxxxxxxxxx V1.1.8.8
11 AppPublisher=xxxxxxxxxxxxxxxx
12 AppPublisherURL=http://www.sdzn.com/
13 AppSupportURL=http://www.sdzn.com/
14 AppUpdatesURL=http://www.sdzn.com/
15 DefaultDirName={pf}\LessonTool
16 DefaultGroupName=xxxxxxxxxxxxxxxx
17 OutputDir=C:\Documents and Settings\Administrator\桌面\備課工具_201200614\
18 OutputBaseFilename=xxxxxxxxxxxxxxxx_20120627_1645_不帶dotFramework
19 Compression=lzma
20 SolidCompression=no
21 
22 [Languages]
23 Name: default; MessagesFile: compiler:Default.isl
24 
25 [Files]
26 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
27 ; 注意: 不要在任何共享的系統文件使用 "Flags: ignoreversion"
28 Source: C:\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
29 Source: ..\..\..\..\Documents and Settings\Administrator\桌面\MMMMMM_201200614\package\Desktop4Bing\*; DestDir: {tmp}
30 
31 [Icons]
32 Name: {group}\{cm:UninstallProgram,xxxxxxxxxxxxxxxx}; Filename: {uninstallexe}
33 Name: {group}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
34 Name: {commondesktop}\xxxxxxxxxxxxxxxx; Filename: {app}\LessonTool.exe
35 
36 [Run]
37 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
38 Filename: {tmp}\hong.exe; WorkingDir: {tmp}\
39 
40 [Messages]
41 WelcomeLabel1=xxxxxxxxxxxxxxxx V1.1.8.8
42 WelcomeLabel2=xxxxxxxxxxxxxxxx V1.1.8.8

 

 

覆蓋.netFramework

 

View Code
 1 ; 腳本用 Inno Setup 腳本向導 生成。
 2 ; 查閱文檔獲取創建 INNO SETUP 腳本文件詳細資料!
 3 
 4 [Setup]
 5 ; 注意: AppId 的值是唯一識別這個程序的標志。
 6 ; 不要在其他程序中使用相同的 AppId 值。
 7 ; (在編譯器中點擊菜單“工具 -> 產生 GUID”可以產生一個新的 GUID)
 8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
 9 AppName=XXXXXXXXXXXXXXXX V1.1.8.8
10 AppVerName=XXXXXXXXXXXXXXXX V1.1.8.8
11 AppPublisher=XXXXXXXXXXMMMMMMMMMMMMMM
12 AppPublisherURL=http://www.sdzn.com/
13 AppSupportURL=http://www.sdzn.com/
14 AppUpdatesURL=http://www.sdzn.com/
15 DefaultDirName={pf}\LessonTool
16 DefaultGroupName=XXXXXXXXXXXXXXXX
17 OutputDir=C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\
18 OutputBaseFilename=XXXXXXXXXXXXXXXX_20120626_0935_覆蓋dotFramework
19 Compression=lzma
20 SolidCompression=yes
21 
22 [Languages]
23 Name: default; MessagesFile: compiler:Default.isl
24 
25 [Files]
26 Source: C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
27 ; 注意: 不要在任何共享的系統文件使用 "Flags: ignoreversion"
28 Source: C:\Documents and Settings\Administrator\桌面\MMMMMMM_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
29 
30 [Icons]
31 Name: {group}\{cm:UninstallProgram,XXXXXXXXXXXXXXXX}; Filename: {uninstallexe}
32 Name: {group}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
33 Name: {commondesktop}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
34 
35 [Run]
36 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
37 Filename: {app}\upgrade\Temp\wic_x86_chs.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安裝Wic,大約需要1分鍾,請稍后……
38 Filename: {app}\upgrade\Temp\dotNetFx40_Full_x86_x64.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安裝.NetFramework,大約需要15分鍾,請稍后……
39 Filename: {app}\upgrade\Temp\vcredist_x86.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; StatusMsg: 安裝VC++支持環境,大約需要1分鍾,請稍后……
40 
41 ;[Registry]
42 ;Root: HKLM; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Run; ValueType: expandsz; ValueName: ThinkTankBox; ValueData: {app}\Bin\ThinkTankBox.exe
43 
44 [Messages]
45 WelcomeLabel1=XXXXXXXXXXXXXXXX V1.1.8.8
46 WelcomeLabel2=XXXXXXXXXXXXXXXX V1.1.8.8

 

檢測.netFramework

 注:若.netFramework不存在,則直接去安裝程序--根據下方腳本編寫

 
View Code
  1 ; 腳本用 Inno Setup 腳本向導 生成。
  2 ; 查閱文檔獲取創建 INNO SETUP 腳本文件詳細資料!
  3 
  4 [Setup]
  5 ; 注意: AppId 的值是唯一識別這個程序的標志。
  6 ; 不要在其他程序中使用相同的 AppId 值。
  7 ; (在編譯器中點擊菜單“工具 -> 產生 GUID”可以產生一個新的 GUID)
  8 AppId={{E47F55B6-5604-4430-A9BE-AE7ADAB5D08C}
  9 AppName=XXXXXXXXXXXXXXXX V1.1.8.8
 10 AppVerName=XXXXXXXXXXXXXXXX V1.1.8.8
 11 AppPublisher=MMMMMMMMMMMMMMMMMMMMMMM
 12 AppPublisherURL=http://www.sdzn.com/
 13 AppSupportURL=http://www.sdzn.com/
 14 AppUpdatesURL=http://www.sdzn.com/
 15 DefaultDirName={pf}\LessonTool
 16 DefaultGroupName=XXXXXXXXXXXXXXXX
 17 OutputDir=C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\
 18 OutputBaseFilename=XXXXXXXXXXXXXXXX_20120626_0935_檢測dotFramework
 19 Compression=lzma
 20 SolidCompression=no
 21 
 22 [Languages]
 23 Name: default; MessagesFile: compiler:Default.isl
 24 
 25 [Files]
 26 Source: C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\package\Debug\*; DestDir: {app}; Flags: ignoreversion recursesubdirs createallsubdirs
 27 ; 注意: 不要在任何共享的系統文件使用 "Flags: ignoreversion"
 28 Source: C:\Documents and Settings\Administrator\桌面\NNNNNNNNN_201200614\package\dsoFramer\*; DestDir: {win}; Languages: 
 29 
 30 [Icons]
 31 Name: {group}\{cm:UninstallProgram,XXXXXXXXXXXXXXXX}; Filename: {uninstallexe}
 32 Name: {group}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
 33 Name: {commondesktop}\XXXXXXXXXXXXXXXX; Filename: {app}\LessonTool.exe
 34 
 35 
 36 [Run]
 37 Filename: {win}\dsoFramer2.bat; WorkingDir: {tmp}; Flags: nowait runminimized
 38 ;Filename: {app}\LiveUpdate\Temp\wic_x86_chs.exe; Parameters: /quiet; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安裝Wic
 39 ;Filename: {app}\LiveUpdate\Temp\dotNetFx40_Full_x86_x64.exe; Parameters: /quiet; WorkingDir: {tmp}; Flags: runhidden; StatusMsg: 安裝.Net
 40 Filename: {app}\upgrade\Temp\vcredist_x86.exe; Parameters: /quiet /norestart; WorkingDir: {tmp}; StatusMsg: 安裝VC++支持環境,大約需要1分鍾,請稍后……
 41 
 42 
 43 [Code]
 44 function InitializeSetup: Boolean;
 45 
 46 var Path:string ;
 47 
 48     ResultCode: Integer;
 49 
 50     dotNetV4RegPath:string;
 51 
 52     dotNetV4PackFile:string;
 53 
 54     wic:string;
 55 
 56 begin
 57 
 58 
 59 dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
 60 
 61 dotNetV4PackFile:='{src}\環境配置\dotNetFx40_Full_x86_x64.exe';
 62 
 63 wic:='{src}\環境配置\wic_x86_chs.exe';
 64 
 65     if RegKeyExists(HKLM, dotNetV4RegPath) then
 66 
 67     begin
 68 
 69         Result := true;
 70 
 71     end
 72 
 73     else
 74 
 75     begin
 76 
 77         Exec(ExpandConstant(wic), '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 78 
 79         if MsgBox('正在安裝NNNNNNNNN必備組件.Net Framework 4.0,此過程將會持續15分鍾左右,請稍后……', mbConfirmation, MB_YESNO) = idYes then
 80 
 81         begin
 82 
 83             Path := ExpandConstant(dotNetV4PackFile);
 84 
 85             if(FileOrDirExists(Path)) then
 86 
 87             begin
 88 
 89                 Exec(Path, '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 90 
 91             end
 92 
 93             else
 94 
 95             begin
 96 
 97                 if MsgBox('軟件安裝目錄中沒有.Net Framework的安裝程序,跳過安裝.Net Framework 4.0?', mbConfirmation, MB_YESNO) = idYes then
 98 
 99                 begin
100 
101                 Result := true;
102 
103                 end
104 
105             end
106 
107         end
108 
109         Result := true;
110 
111     end;
112 
113 end;

 

 
[Pascal腳本]檢測.netFramework
若.netFramework不存在,則去安裝包所在目錄去尋zhaoFramework,然后安裝
若Framework尋找不到,則去下載.netFramework,然后手動安裝,然
后我們的程序才可以繼續安裝
 
View Code
  1 [Code]
  2 function InitializeSetup: Boolean;
  3 
  4 var Path:string ;
  5 
  6     ResultCode: Integer;
  7 
  8     dotNetV4RegPath:string;
  9 
 10     dotNetV4DownUrl:string;
 11 
 12     dotNetV4PackFile:string;
 13 
 14     wic:string;
 15 
 16 begin
 17 
 18 
 19 dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
 20 
 21 dotNetV4DownUrl:='http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe';
 22 
 23 dotNetV4PackFile:='{src}\update\dotNetFx40_Full_x86_x64.exe';
 24 
 25 wic:='{src}\update\wic_x86_chs.exe';
 26 
 27   if RegKeyExists(HKLM, dotNetV4RegPath) then
 28 
 29   begin
 30 
 31     Result := true;
 32 
 33   end
 34 
 35   else
 36 
 37   begin
 38 
 39     Exec(ExpandConstant(wic), '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 40 
 41     if MsgBox('系統檢測到您沒有安裝.Net Framework4.0運行環境,是否立即安裝?', mbConfirmation, MB_YESNO) = idYes then
 42 
 43     begin
 44 
 45 
 46 
 47       Path := ExpandConstant(dotNetV4PackFile);
 48 
 49       if(FileOrDirExists(Path)) then
 50 
 51       begin
 52 
 53         Exec(Path, '/q /norestart', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 54 
 55         if RegKeyExists(HKLM, dotNetV4RegPath) then
 56 
 57         begin
 58 
 59            Result := true;
 60 
 61         end
 62 
 63         else
 64 
 65         begin
 66 
 67            MsgBox('未能成功安裝.Net Framework4.0運行環境,系統將無法運行,本安裝程序即將退出!',mbInformation,MB_OK);
 68 
 69         end
 70 
 71       end
 72 
 73       else
 74 
 75       begin
 76 
 77         if MsgBox('軟件安裝目錄中沒有包含.Net Framework的安裝程序,是否立即下載后安裝?', mbConfirmation, MB_YESNO) = idYes then
 78 
 79         begin
 80 
 81           Path := ExpandConstant('{pf}\Internet Explorer\iexplore.exe');
 82 
 83           Exec(Path, dotNetV4DownUrl , '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 84 
 85           MsgBox('請安裝好.Net Framework4.0環境后,再運行本安裝包程序!',mbInformation,MB_OK);
 86 
 87           Result := false;
 88 
 89         end
 90 
 91         else
 92 
 93         begin
 94 
 95           MsgBox('不下載安裝.Net Framework4.0運行環境,系統將無法運行,本安裝程序即將退出!',mbInformation,MB_OK);
 96 
 97           Result := false;
 98 
 99         end
100 
101       end
102 
103     end
104 
105     else
106 
107     begin
108 
109       MsgBox('沒有安裝.Net Framework4.0運行環境,系統將無法運行,本安裝程序即將退出!',mbInformation,MB_OK);
110 
111       Result := false;
112 
113     end;
114 
115   end;
116 
117 end;

 

InnoSetup打包常用代碼集錦

View Code
Inno setup常用代碼【收藏】


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)

15if 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.google.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

22、安裝完成后顯示新特性
[Run]
Filename: "{app}\WhatsNew.Txt"; Description: "安裝完成后顯示新特性"; Flags: postinstall shellexec skipifsilent
 
23、安裝卸載前檢測軟件是否在運行
說明:安裝前用FindWindowByClassName檢測迅雷程序是否在運行,注意這個循環語句。
用MicroSoft spy++找有關的程序的ClassName,迅雷的class是TfrmCmdCenter(以TfrmCmdCenter來檢測迅雷是否在運行的)。
[Code]
var
is_value: integer;
function InitializeSetup(): Boolean;
begin
Result :=true;
is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
while is_value<>0 do
begin
if Msgbox(‘安裝程序檢測到您的迅雷軟件當前正在運行。’ #13#13 ‘您必須先關閉它然后單擊“是”繼續安裝,或按“否”退出!’, mbConfirmation, MB_YESNO) = idNO then
begin
Result :=false; //安裝程序退出
is_value :=0;
end else begin
Result :=true; //安裝程序繼續
is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
end;
end;
end;
function InitializeUninstall(): Boolean;
begin
is_value:=FindWindowByClassName(‘TfrmCmdCenter’);
if is_value<>0 then begin
MsgBox(‘卸載程序檢測到您的迅雷軟件當前正在運行。’ #13#13 ‘為了更安全完整的卸載,您必須關閉它在進行卸載操作!’, mbError, MB_OK);
Result :=false;
end else Result :=true;
end;
 
24、自定義安裝程序右上角圖片大小
[code]
procedure InitializeWizard();
begin
WizardForm.WizardSmallBitmapImage.width:=150; //設置頁眉圖片的大小
WizardForm.WizardSmallBitmapImage.left:=WizardForm.width-150; //設置左邊頁眉留出的空隙
WizardForm.PAGENAMELABEL.width:=0; //設置標題文字顯示的大小
WizardForm.PAGEDESCRIPTIONLABEL.width:=0; //設置標題文字顯示的大小
end;
 
25、跳關安裝程序的歡迎界面
INNO 的設計中本身可以跳過所有向導頁面(用 ShouldSkipPage 函數),但是唯獨不能跳過歡迎頁面,據說作者是有意為了防止該功能被濫用,即產生完全沒有界面的在后台運行的安裝程序。
要跳過歡迎頁面,只能調用系統的功能。
參考一
復制內容到剪貼板代碼:
[Code]
const
WM_LBUTTONDOWN = 513;
WM_LBUTTONUP = 514;
procedure InitializeWizard();
begin
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONDOWN,0,0);
PostMessage(WizardForm.NextButton.Handle,WM_LBUTTONUP,0,0);
// 其它代碼
end;
參考二
復制內容到剪貼板代碼:
[Code]
procedure CurPageChanged(CurPageID: Integer);
begin
if CurPageID = wpWelcome then
WizardForm.NextButton.OnClick(WizardForm);
end;
兩者都能跳過歡迎頁面
 
26、跳過准備安裝界面
使用inno打包,我們會注意到,在選擇好安裝向導所指定的所有項目后,安裝向導會進入一個准備安裝的界面提示你所有的安裝信息。此時,我們只能點擊安裝按鈕,安裝才可以繼續。有時候,為了某種需要,我們可能不想讓程序顯示這個准備安裝的界面,那么如何去掉這個界面呢?請看以下的代碼:
[code]
function ShouldSkipPage(PageID: Integer): Boolean;
begin
if PageID=wpReady then
result := true;
end;
 
27、判斷注冊表檢查程序時候存在
有時候,我們制作軟件的漢化或者補丁程序,需要判斷軟件是否已安裝,如果軟件已安裝就安裝此補丁,如果軟件未安裝就終止安裝程序並且提示用戶安裝原版軟件后再運行此補丁,那么如何實現此功能呢,這里就給大家提供一個我的判斷實力。通過檢查注冊表相關鍵值來判斷指定程序是否已安裝,以下是我制作的一個程序的增強補丁,需要在源程序安裝的基礎上進行安裝,具體腳本判斷如下:
[CODE]
var
MyKeyExist: boolean;
function InitializeSetup(): boolean;
begin
MyKeyExist:= true;
if Not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Adobe\Audition\3.0', 'ApplicationPath') then
begin
MyKeyExist:= false;
MsgBox('安裝程序檢測到您的系統內沒有安裝Adobe Audition3.0,請先安裝軟件在運行此補丁。', mbInformation, MB_OK);
end;
Result:= MyKeyExist;
end;
 
28、如何讓協議許可頁面默認選中我同意按鈕
為了讓初學者更方便的安裝軟件,有時候我們會發現一些使用inno setup打包的程序在許可頁面默認已經選中了我同意按鈕,只需要點擊下一步即可繼續安裝,那么這個效果是如何實現的呢?下面是代碼:
[code]
procedure InitializeWizard();
begin
WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;
 
29、安裝前檢測是否已經安裝
function InitializeSetup(): boolean;
begin
Result := true;
if FileExists(ExpandConstant('{pf}\我的程序\我的程序.exe')) then
begin
MsgBox('程序已經安裝在你的系統中了,請先卸載!', mbInformation, MB_OK );
Result := false;
end;
end;
其中{pf}\我的程序\我的程序.exe替換為你自己的路徑即可
加入此代碼的含義,就是檢測目錄下是否包括代碼中指定的文件名的文件,如果有則當您運行程序后直接彈出提示告訴您軟件已經存在,請先卸載。因此,這個代碼有個局限性,就是只能檢測固定的目錄的文件,如果用戶的文件並未安裝到腳本所指定的檢測目錄,那么就將無法檢測到。所以,判斷也就失效了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM