Inno Setup
Inno Setup 是一个免费的安装制作软件(开源),它既有适合新手的脚本向导,又有良好的脚本编辑环境,能够快速制作出标准 Windows2000 风格 的安装界面,足以完成一般的安装任务,在新版本版中软件加入了对多语言的支持,这个功能的实现相较于 NSIS 来得简单多了, 推荐大家使用新的版本。.
背景
一般我们开发好的客户端软件交付的时候,都是需要生成安装包exe给到用户手中。Inno Setup这时候就派上用场。winform一般需要检查当前 .NET Framework 环境并安装。
实现方式
1、安装过程中连接官网下载地址 下载到本地 进行安装
2、将脱机安装文件和安装包打包在一起 安装时直接读取本地文件进行安装
实现方法
下面我们重点看下第二种方法
if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\full','release',HistoryBufferSize) then
begin
RegeditValue:=HistoryBufferSize;
// MsgBox('Your country: ' + IntToStr(RegeditValue),mbConfirmation, MB_OK);
if(RegeditValue>=394254) then
begin
// Result:=true;
end
else
begin
if MsgBox('检测到系统没有安装.Net Framework4.6.1!'+#13#10#13#10 +'是否退出此次安装?',mbInformation,MB_YESNO)=IDYES then
begin
// Result:=false;
Isnet:=false;
end
else
begin
// Result:=true;
MsgBox('程序执行需要NET的支持,安装可能需要2、3分钟,开始安装',mbConfirmation, MB_OK);
ExtractTemporaryFile('NDP461-KB3102436-x86-x64-AllOS-ENU.exe');
Exec(ExpandConstant('{tmp}\NDP461-KB3102436-x86-x64-AllOS-ENU.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
end
end
end
else
begin
if MsgBox('检测到系统没有安装.Net Framework4.6.1!'+#13#10#13#10 +'是否退出此次安装?',mbInformation,MB_YESNO)=IDYES then
begin
// Result:=false;
Isnet:=false;
end
else
begin
// Result:=true;
MsgBox('程序执行需要NET的支持,安装可能需要2、3分钟,开始安装',mbConfirmation, MB_OK);
ExtractTemporaryFile('NDP461-KB3102436-x86-x64-AllOS-ENU.exe');
Exec(ExpandConstant('{tmp}\NDP461-KB3102436-x86-x64-AllOS-ENU.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
end
end;
//MsgBox('Your country: ' + Isnet,mbConfirmation, MB_OK);
//测试退出的
// Isnet:=false;
if Isnet then
begin
// MsgBox('开始安装.Net Framework4.6.1 ',mbConfirmation, MB_OK);
// if not RegValueExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Classes\CLSID\{6F3DD387-5AF2-492B-BDE2-30FF2F451241}\InprocServer32\12.0.0.0', 'RuntimeVersion') then begin
// MsgBox('Access安装出错:' #13#13 ' ' + '.', mbError, MB_OK);
// ExtractTemporaryFile('NDP461-KB3102436-x86-x64-AllOS-ENU.exe');
// Exec(ExpandConstant('{tmp}\NDP461-KB3102436-x86-x64-AllOS-ENU.exe'), '', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode)
// end ;
end
else
begin
// MsgBox('不要了,退出 ',mbConfirmation, MB_OK);
IsSetup := false ;
end;