gpt4 book ai didi

c# - 检查是否使用注册表安装了自定义先决条件

转载 作者:太空宇宙 更新时间:2023-11-03 12:33:55 24 4
gpt4 key购买 nike

我正在为我的应用程序创建一个 CLickOnce 安装程序,它依赖于另一个应用程序来工作。我希望安装程序在安装我自己的应用程序之前安装其他应用程序(如果尚未安装)。

为此,我在 these (MSDN) 之后创建了一个自定义先决条件指示。截至目前,安装程序会先安装其他应用程序,然后再安装我的应用程序,但不会检查其他应用程序是否已安装。

根据其他先决条件的示例,我在我的先决条件 list 中创建了一个安装检查,以检查包含应用程序版本的注册表项的值。问题是注册表检查总是无法读取注册表。我尝试了许多其他注册表项,但无法读取它们。正常工作的是:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\SharedManagementObjects\CurrentVersion - Version

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer - Version

以及默认 Bootstrap 包(DotNetFX40、SqlExpress2012 等)使用的其他 key 。

这是怎么回事?为什么安装程序无法读取大多数注册表项?


我的产品.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Product
xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper"
ProductCode="TestAppSetup"
/>

和我的 package.xml

<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/developer/2004/01/bootstrapper" Name="Test" Culture="Culture">

<!-- Defines list of files to be copied on build -->
<PackageFiles>
<PackageFile Name="TestApp.exe"/>
</PackageFiles>

<InstallChecks>
<RegistryCheck Property="TestVersion" Key="REGISTRY_KEY_HERE" Value="Version" />
</InstallChecks>

<Commands Reboot="Defer">
<Command PackageFile="TestApp.exe" Arguments="">

<!-- These checks determine whether the package is to be installed -->
<InstallConditions>
<!-- Bypasses if TestApp version 3.6.3 or above is already installed -->
<BypassIf Property="TestApp" Compare="ValueGreaterThanOrEqualTo" Value="3.6.3"/>
<!-- Block install if user does not have admin privileges -->
<FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired"/>
<!-- Block install on less than Windows XP SP2 -->
<FailIf Property="VersionNT" Compare="VersionLessThan" Value="5.1.2" String="InvalidPlatformWinNT"/>
<!-- Block install on W2K3 with no service pack -->
<FailIf Property="VersionNT" Compare="VersionEqualTo" Value="5.2.0" String="InvalidPlatformWinNT"/>
<!-- Block install if the platform is IA-64 -->
<FailIf Property="ProcessorArchitecture" Compare="ValueEqualTo" Value="IA64" String="InvalidPlatformArchitecture" />
</InstallConditions>

<ExitCodes>
<ExitCode Value="0" Result="Success"/>
<ExitCode Value="1602" Result="Fail" String="UserCancelled"/>
<ExitCode Value="1603" Result="Fail" String="GeneralFailure"/>
<ExitCode Value="3010" Result="SuccessReboot"/>
<DefaultExitCode Result="Fail" FormatMessageFromSystem="true" String="GeneralFailure" />
</ExitCodes>
</Command>
</Commands>

<!-- Defines a localizable string table for error messages-->
<Strings>
<String Name="DisplayName">TestApp</String>
<String Name="Culture">en</String>
<String Name="AdminRequired">Administrator permissions are required to install TestApp. Contact your administrator.</String>
<String Name="InvalidPlatformWinNT">Installation of TestApp requires Windows XP SP2, Windows 2003 SP1, Windows Vista, or later. Contact your application vendor.</String>
<String Name="InvalidPlatformArchitecture">This version of TestApp is not supported on an IA-64 operating system. Contact your application vendor.</String>
<String Name="UserCancelled">The user has cancelled the installation. TestApp has not been installed.</String>
<String Name="GeneralFailure">A failure occurred attempting to install TestApp.</String>
</Strings>
</Package>

谢谢

最佳答案

我发现了问题...

clickOnce 安装程序是 32 位进程,操作系统是 64 位,因此注册表检查 key 会自动重定向到 WOW6432Node。

关于c# - 检查是否使用注册表安装了自定义先决条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41723892/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com