如何使用Inno检测和安装先决条件? [英] How to detect and install prerequisite(s) using Inno?

查看:102
本文介绍了如何使用Inno检测和安装先决条件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为使用Inno的应用安装一些先决条件.我希望先决条件仅在先决条件不存在或为较早版本时才安装.我发现了一些解决方案,例如:

I need to install some prerequisites for an app using Inno. I want the prerequisites to only install if the prerequisite does not exist or is an earlier version. I have found some solutions such as:

[Code]
procedure InstallFramework;
var
  ResultCode: Integer;
begin
  if not Exec(ExpandConstant('{tmp}\NDP472-KB4054530-x86-x64-AllOS-ENU.exe'), '/q /norestart', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  begin
    { you can interact with the user that the installation failed }
    MsgBox('.NET installation failed with code: ' + IntToStr(ResultCode) + '.',
      mbError, MB_OK);
  end;
end;

这看起来好像不是要检查框架是否已经存在或可能已经安装了哪个版本.

That does not look like it checks to see if the framework exists already or what version may already be installed.

用于查找先前安装的版本的模式是什么,如果存在,则检查版本,如果该版本较旧或不存在,则进行安装?

What is the pattern to use to look for a previously installed version, if it exists then check version and if version is older or does not exist then install?

推荐答案

这是一个简单的答案,可以指导您采用多种可能的解决方案之一.

This a simple answer to head you in one of many possible solutions.

在测试环境(或您的计算机)中,您将安装应用程序和所有必需的组件,以使它们出现在控制面板的程序和功能"中

In the testing environment (or in your computer) you install the application and all the required components, so you have them appear in the control panel's Programs and Features

然后,您在注册表中搜索程序和功能中出现的名称

Then you search in the registry for the name that appears in the Programs and Features

您要查找包含该名称的值DisplayName.您可以在

You want to find the value DisplayName that contains that name. You'll find it in one key of

HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Uninstall \, HKEY_LOCAL_MACHINE \ SOFTWARE \ WOW6432Node \ Microsoft \ Windows \ CurrentVersion \ Uninstall \

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\, HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\

HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall

,取决于安装类型.

注意:如果对应键中的SystemComponent值为1,则可以从程序和功能"中隐藏某些组件.

Note: Some components can be hidden from the Programs and Features if the value SystemComponent is 1 in the correspondent key.

然后,您可以在pascal脚本中使用类似这样的命令来检查注册表项的存在性

Then you can check the registry key existence with something like this in pascal script

[Code]
function test(bitness: integer; productCode: String): Boolean;
begin
    if RegValueExists(bitness, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + productCode, 'DisplayName') then Result := True else Result := False;
end;

您可以在函数PrepareToInstall(var NeedsRestart:Boolean):String;中调用此函数.或使用检查参数(搜索inno设置帮助)

You can call this function inside function PrepareToInstall(var NeedsRestart: Boolean): String; or using check parameters (search in inno setup help)

这篇关于如何使用Inno检测和安装先决条件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆