inno setup安裝包程序完整版

以下是一個短小精悍型的打包程序,先記錄下來,以備忘。

 

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

;是否安裝驅動
#define IncludeDrive 0
#define IsExternal ""

;安裝包exe的輸出路徑
#define OutPutDirectory "E:\項目\Zebra"  

;組件驅動路徑
#define MyInnoCommonDirectory "E:\項目\驅動"

;文件路徑
#define MyFileDirectory "E:\Software\Codes\Trunk\ZebraControl\Bin"

;版本
#define version "0.1.12"

;程序名稱
#define appname "Zebra"

;運行exe名稱
#define MyAppExeName "BGI Sequence Control Software.exe"

;窗口名稱
#define AppWindowName "BGI Sequence Control Software"
 
;程序運行提示
#define RunningNotice "安裝程序檢測到客戶端正在運行,請先退出!"

;公司網站
#define MyAppURL "http://www.it.com"


[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{14A54E41-6A63-4842-A799-2D95BE9E60A0}
AppName={#appname}
AppVersion={#version}
AppVerName={#appname} {#version}
DefaultDirName={sd}\{#appname}
DefaultGroupName={#appname}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}

;輸出目錄
OutputDir={#OutPutDirectory}

;輸出文件名
OutputBaseFilename={#appname} {#version}
Compression=lzma
SolidCompression=yes

VersionInfoVersion={#version}

;提示是否覆蓋
DirExistsWarning = yes

;許可證說明
LicenseFile=compiler:license.txt

;很重要,將顯示所有語言
ShowUndisplayableLanguages=yes

[Languages]
Name: "chs"; MessagesFile: "compiler:Languages\ChineseSimplified.isl"
Name: "eng"; MessagesFile: "compiler:Default.isl"
  
[Messages]
chs.BeveledLabel=Chinese
eng.BeveledLabel=English
 
[Tasks]
;創建桌面快捷方式,默認選中
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}";

[Files]
;拷貝文件夾及子文件夾的所有文件
;Source: {#MyFileDirectory}\*.lib; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\*.dll; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\*.exe; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: {#MyFileDirectory}\Config\*.txt; DestDir: "{app}\Config"; Flags: onlyifdoesntexist
Source: {#MyFileDirectory}\Log\*.db; DestDir: "{app}\Log"; Flags: onlyifdoesntexist
Source: {#MyFileDirectory}\Recipe\*.xml; DestDir: "{app}\Recipe"; Flags: onlyifdoesntexist

; NOTE: Don't use "Flags: ignoreversion" on any shared system files
;安裝驅動,不需要打包,先放到臨時目錄下
#if IncludeDrive
Source: "{#MyInnoCommonDirectory}\driv_win_smart_v1.22_build_14030711_whql\disk.x64\mxspinst.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\PCO相機驅動\DI_USB3_WXP_W7_W8_V109.EXE"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\RENESAS-USB3-Host-Driver\RENESAS-USB3-Host-Driver-30200-setup.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
Source: "{#MyInnoCommonDirectory}\camware\SW_CAMWAREWIN64_316.exe"; DestDir: "{tmp}"; Flags: ignoreversion {#IsExternal};
#endif

[Icons]
Name: "{group}\{#appname}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#appname}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppExeName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

;卸載前刪除安裝目錄
[UninstallDelete]
;Type: filesandordirs; Name: "{app}"
Type: filesandordirs; Name: "{app}\temp"
Type: filesandordirs; Name: "{app}\Config"
Type: filesandordirs; Name: "{app}\Log"
Type: filesandordirs; Name: "{app}\Recipe"

;安裝前先刪除
[InstallDelete]
Type: filesandordirs; Name: "{app}\temp"
Type: filesandordirs; Name: "{app}\unins000.dat"
Type: filesandordirs; Name: "{app}\unins000.exe"

;刪除快捷方式
Type: filesandordirs; Name:"{group}\*"

[Registry]
Root: HKLM; Subkey: "Software\MKT\SQL"; ValueType: string; ValueName: name; ValueData: sql; Flags: createvalueifdoesntexist uninsdeletevalue

[Run]
;運行驅動,從臨時目錄下取文件,不打包到安裝目錄下
#if IncludeDrive
Filename: {tmp}\mxspinst.exe; WorkingDir: "{tmp}"; Flags: skipifdoesntexist runascurrentuser; StatusMsg: "Installing mxspinst..."
Filename: {tmp}\DI_USB3_WXP_W7_W8_V109.EXE; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing DI_USB3_WXP_W7_W8_V109..."
Filename: {tmp}\RENESAS-USB3-Host-Driver-30200-setup.exe; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing RENESAS-USB3-Host-Driver..."
Filename: {tmp}\SW_CAMWAREWIN64_316.exe; WorkingDir: "{tmp}"; Flags:  skipifdoesntexist runascurrentuser; StatusMsg: "Installing SW_CAMWAREWIN64_316..."
#endif
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#appname}}"; Flags: nowait postinstall unchecked skipifsilent runascurrentuser

[INI] 
;Filename: "{app}\lan\setup.ini"; Section: "set"; Key: "lan"; String: "{code:MyLangName|{app}}"; Flags: uninsdeletesection

[Code]
//默認選擇同意(安裝的協議)
procedure InitializeWizard();
begin
  WizardForm.LICENSEACCEPTEDRADIO.Checked := true;
end;

 // 判斷註冊表

function InitializeSetup():Boolean;   
var  
  KeynotExist:boolean;
  msg:String;
     
begin   
  KeynotExist := true; 
     
  if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\MKT\SQL', 'name') then   
  begin   
    KeynotExist := false;
      msg := ‘已安裝過,不用再安裝’;
    MsgBox(msg,mbConfirmation, MB_OK);   
  end;   
  Result := KeynotExist   
end; 

// 根據選擇的語言加載相應的配置文件
function MyLangName(Param : String): String;       
begin              
  Result := ActiveLanguage(); 
end;

// 安裝時判斷客戶端是否正在運行
function InitializeSetup(): Boolean;
var IsRunning: Integer;
begin
  Result :=true; //安裝程序繼續
  IsRunning:=FindWindowByWindowName('{#AppWindowName}');
  if IsRunning <> 0 then
  begin
    Msgbox('{#RunningNotice}', mbConfirmation, MB_OK);
    Result :=false; //安裝程序退出
  end;
end;

// 卸載時判斷客戶端是否正在運行
function InitializeUninstall(): Boolean;
var IsRunning: Integer;
begin
  Result :=true; //安裝程序繼續
  IsRunning:=FindWindowByWindowName('{#AppWindowName}');
  if IsRunning <> 0 then
  begin
    Msgbox('{#RunningNotice}', mbConfirmation, MB_OK);
    Result :=false; //安裝程序退出
  end;
end;

 


 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章