1. 程式人生 > >分享個INNO打包Windows應用程式完整例項指令碼

分享個INNO打包Windows應用程式完整例項指令碼

最近手賤,把以前寫的一個完整的INNO打包指令碼給刪了,於是又得到處找資料學習。現在分享一個完整的指令碼程式碼,以後就不會找不到了。指令碼為完整diamante,包括了這些基本的功能:寫登錄檔、檢測程式是否正在執行、呼叫exe、配置生成檔案相關屬性等。

; 指令碼由 Inno Setup 指令碼嚮導 生成!
; 有關建立 Inno Setup 指令碼檔案的詳細資料請查閱幫助文件!

#define MyAppName "××××"
#define MyAppVersion "2.3.29.15"
#define MyAppPublisher "有限公司"
#define MyAppURL "http://www.******.com/"
#define MyAppExeName "******.exe"
;#define MyProgramsMutexName "C0BD666C-45AB-48D2-AAA8-C535E624134C"
[Setup]
; 注: AppId的值為單獨標識該應用程式。
; 不要為其他安裝程式使用相同的AppId值。
; (生成新的GUID,點選 工具|在IDE中生成GUID。)
AppId={{C0BD666C-45AB-48D2-AAA8-C535E624134C}
;AppMutex={#MyProgramsMutexName}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
VersionInfoProductVersion={#MyAppVersion}
VersionInfoProductTextVersion={#MyAppVersion}
VersionInfoVersion={#MyAppVersion}
VersionInfoCompany={#MyAppPublisher}
VersionInfoCopyright={#MyAppPublisher}{#'版權所有'}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DefaultGroupName={#MyAppName}

OutputDir=C:\Users\Jelin\Desktop\InnoOut
OutputBaseFilename=MySetup{#MyAppVersion}
SetupIconFile=******\res\*****.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "E:\<span style="font-family: Arial, Helvetica, sans-serif;">******</span><span style="font-family: Arial, Helvetica, sans-serif;">\Release\****.exe"; DestDir: "{app}"; Flags: ignoreversion</span>
Source: "E:\*****\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 注意: 不要在任何共享系統檔案上使用“Flags: ignoreversion”

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[UninstallRun]
Filename: "{app}\******.exe"; Parameters: "/uninstall"

;登錄檔啟動項 
[Registry] 
Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "testrun"; ValueData: "{app}\{#MyAppExeName}" 
Root: HKLM; Subkey: "Software\**********"; ValueType: string; ValueName: "version"; ValueData: "{#MyAppVersion}"
Root: HKLM; Subkey: "Software\<span style="font-family: Arial, Helvetica, sans-serif;">**********</span><span style="font-family: Arial, Helvetica, sans-serif;">"; ValueType: string; ValueName: "path"; ValueData: "{app}"</span>

;安裝時判斷客戶端是否正在執行    
[Code]
 
function InitializeSetup(): Boolean;  
var 
  IsRunning: Integer;
begin  
   
Result :=true; //安裝程式繼續  
    
IsRunning:=FindWindowByClassName('UIMainFrame');  ;檢查程式是否正在執行
   
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:=FindWindowByClassName('UIMainFrame');  
   
end;  
   
end;  
   
end;


function InitializeUninstall(): boolean;
var
IsRunning: Integer;
begin
  Result:= true;
  IsRunning:= FindWindowByClassName('UIMainFrame');  
  begin
    if IsRunning<>0 then
    begin
      MsgBox('******正在執行,請先關閉它!', mbConfirmation, MB_OK);
      Result:= false;
    end
    else
      begin
      Result:= true

      end;
  end;
end;