InnoSetup打包检测.netFramework的问题

该程序用于检查系统是否已安装.NET Framework 4.0,并根据检测结果进行相应处理,包括提示用户安装或下载.NET Framework 4.0。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[code]function InitializeSetup: Boolean;
 
var Path:string ;
 
     ResultCode: Integer;
 
     dotNetV4RegPath:string;
 
     dotNetV4DownUrl:string;
 
     dotNetV4PackFile:string;
 
     wic:string;
 
begin
 
 
dotNetV4RegPath:='SOFTWARE\Microsoft\.NETFramework\policy\v4.0';
 
dotNetV4DownUrl:='http://download.microsoft.com/download/9/5/A/95A9616B-7A37-4AF6-BC36-D6EA96C8DAAE/dotNetFx40_Full_x86_x64.exe';
 
dotNetV4PackFile:='{src}\update\dotNetFx40_Full_x86_x64.exe';
 
wic:='{src}\update\wic_x86_chs.exe';
 
   if RegKeyExists(HKLM, dotNetV4RegPath) then
 
   begin
 
     Result := true;
 
   end
 
   else
 
   begin
 
     Exec(ExpandConstant(wic), '/q /norestart''', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 
     if MsgBox('系统检测到您没有安装.Net Framework4.0运行环境,是否立即安装?', mbConfirmation, MB_YESNO) = idYes then
 
     begin
 
 
 
       Path := ExpandConstant(dotNetV4PackFile);
 
       if(FileOrDirExists(Path)) then
 
       begin
 
         Exec(Path, '/q /norestart''', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 
         if RegKeyExists(HKLM, dotNetV4RegPath) then
 
         begin
 
            Result := true;
 
         end
 
         else
 
         begin
 
            MsgBox('未能成功安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
 
         end
 
       end
 
       else
 
       begin
 
         if MsgBox('软件安装目录中没有包含.Net Framework的安装程序,是否立即下载后安装?', mbConfirmation, MB_YESNO) = idYes then
 
         begin
 
           Path := ExpandConstant('{pf}\Internet Explorer\iexplore.exe');
 
           Exec(Path, dotNetV4DownUrl , '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
 
           MsgBox('请安装好.Net Framework4.0环境后,再运行本安装包程序!',mbInformation,MB_OK);
 
           Result := false;
 
         end
 
         else
 
         begin
 
           MsgBox('不下载安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
 
           Result := false;
 
         end
 
       end
 
     end
 
     else
 
     begin
 
       MsgBox('没有安装.Net Framework4.0运行环境,系统将无法运行,本安装程序即将退出!',mbInformation,MB_OK);
 
       Result := false;
 
     end;
 
   end;
 
end;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值