http://blog.csdn.net/guoquanyou/article/details/7445773
InnoSetup真是一个非常棒的工具.给我的印象就是非常的精干.所以,该工具已经一步步的把我的InstallerVise代替了.InnoSetup最棒的在于他的脚本语言,完全的pascal语法,你可以在学习他的时候省去很多麻烦.
用InnoSetup的wizard已经可以完成很多的工作了,但是并不是十全十美.许多地方要你自己订定,这就用到脚本了.
默认的打包好的程序在程序菜单中没有卸载图标,这一点很不爽.你要卸载程序要通过添加/删除程序来完成,这太麻烦了.其实只需要几步就可以完成这一工作.
; 脚本由 Inno Setup 脚本向导 生成!
; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
#define MyAppName "青岛招聘网"
#define MyAppVersion "1.5"
#define MyAppPublisher "青岛招聘网"
#define MyAppURL "http://www.qk12333.com/"
#define MyAppExeName "Client.exe"
[Setup]
; 注: AppId的值为单独标识该应用程序。
; 不要为其他安装程序使用相同的AppId值。
; (生成新的GUID,点击 工具|在IDE中生成GUID。)
AppId={{E8EA32EC-AE79-4184-A374-4356A6BDBC16}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes
Uninstallable=yes
UninstallDisplayName=卸载{#MyAppName}
[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked; OnlyBelowVersion: 0,6.1
[Files]
Source: "C:Client.rootClientinDebugClient.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:Client.rootClientinDebugAxInterop.WMPLib.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:Client.rootClientinDebugClient.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:Client.rootClientinDebugClient.pdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:Client.rootClientinDebugInterop.WMPLib.dll"; DestDir: "{app}"; Flags: ignoreversion
; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
[code]
function InitializeSetup: Boolean;
var Isbl: boolean; //声明变量
var Isstr: string;
//全局变量
var MyProgChecked: Boolean;
var Path:string ;
ResultCode: Integer;
begin
if RegKeyExists(HKLM, 'SOFTWAREMicrosoft.NETFrameworkpolicyv2.0') then
begin
Result := true;
end
else
begin
if MsgBox('系统检测到您没有安装.Net Framework2.0,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
begin
Path := ExpandConstant('{pf}Internet Exploreriexplore.exe');
Exec(Path, 'http://data.zhiluo.net/soft/Microsoft_DotNet2.0.rar', '' , SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
MsgBox('请安装好.Net Framework2.0环境后,再运行本安装包程序!',mbInformation,MB_OK);
Result := false;
end
else
begin
MsgBox('没有安装.Net Framework2.0环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
Result := false;
end;
end;
begin //开始
Isbl := true; //变量赋值 注意下方的“SOFTWAREIT_soft”要与安装时创建的注册表信息一致
Isstr := '欢迎';
if RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWAREIT_soft', 'config') then
begin
MsgBox('软件已安装过,如果需要重新安装,请先卸载再安装!',mbConfirmation, MB_OK);
isbl := false;
end
else
begin
//MsgBox('无值',mbConfirmation, MB_OK);
isbl := true;
end;
Result := Isbl;
end; //结束
end;
[Icons]
Name: "{group}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"
Name: "{commondesktop}{#MyAppName}"; Filename: "{app}{#MyAppExeName}"; Tasks: desktopicon
Name: "{group}卸载 {#MyAppName}"; Filename: "{uninstallexe}"
[Run]
Filename: "{app}{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent