加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

.net-4.0 – .NET Framework作为Inno-Setup安装的先决条件

发布时间:2020-12-15 04:21:18 所属栏目:大数据 来源:网络整理
导读:我有一个应用程序,我必须检查是否已安装.NET FW 3.5.如果已安装,我想打开一个消息框,要求用户从Microsoft网站下载并停止安装. 我找到了以下代码.你能告诉我吗: a)我应该从哪里调用此函数? b)我应该检查是否已安装.NET FW 3.5或更高版本?例如如果安装了FW
我有一个应用程序,我必须检查是否已安装.NET FW 3.5.如果已安装,我想打开一个消息框,要求用户从Microsoft网站下载并停止安装.

我找到了以下代码.你能告诉我吗:

a)我应该从哪里调用此函数?
b)我应该检查是否已安装.NET FW 3.5或更高版本?例如如果安装了FW 4.0 – 是否需要安装3.5?

谢谢

function IsDotNET35Detected(): Boolean;
var
  ErrorCode: Integer;
  netFrameWorkInstalled : Boolean;
  isInstalled: Cardinal;
begin
  result := true;

  // Check for the .Net 3.5 framework
  isInstalled := 0;
  netFrameworkInstalled := RegQueryDWordValue(HKLM,'SOFTWAREMicrosoftNET Framework SetupNDPv3.5','Install',isInstalled);
  if ((netFrameworkInstalled)  and (isInstalled <> 1)) then netFrameworkInstalled := false;

  if netFrameworkInstalled = false then
  begin
    if (MsgBox(ExpandConstant('{cm:dotnetmissing}'),mbConfirmation,MB_YESNO) = idYes) then
    begin
      ShellExec('open','http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
    end;
    result := false;
  end;

end;

解决方法

如果要在安装开始时但在显示向导表单之前执行检查,请使用 InitializeSetup事件处理程序.当您将False返回到该处理程序时,安装程??序将中止,当为True时,安装程??序将启动.这是您发布的一些优化脚本:
[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}My Program

[CustomMessages]
DotNetMissing=.NET Framework 3.5 is missing. Do you want to download it ? Setup will now exit!

[Code]
function IsDotNET35Detected: Boolean;
var
  ErrorCode: Integer;
  InstallValue: Cardinal;  
begin
  Result := True;
  if not RegQueryDWordValue(HKLM,InstallValue) or (InstallValue <> 1) then
  begin
    Result := False;
    if MsgBox(ExpandConstant('{cm:DotNetMissing}'),MB_YESNO) = IDYES then
      ShellExec('',ErrorCode);
  end;
end;

function InitializeSetup: Boolean;
begin
  Result := IsDotNET35Detected;
end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读