gpt4 book ai didi

wix - 在 WiX Bundle 中基于 RegistrySearch 隐藏文本

转载 作者:行者123 更新时间:2023-12-04 04:41:51 26 4
gpt4 key购买 nike

是否可以使用 RegistrySearch在 WiX 包中隐藏 Text在主题?
我不知道从哪里开始。在下面的代码中,InstalledDotNet4变量未设置 Text及时禁用,我找不到禁用 Text 的方法(或更改其文本内容)。

捆绑.wxs:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="My App" Version="1.0.0.0"
Manufacturer="ACME"
UpgradeCode="d88faa97-2197-4154-9e77-32f9ca773bd4">

<BootstrapperApplicationRef
Id="WixExtendedBootstrapperApplication.HyperlinkLicense">

<Payload SourceFile="Resources/background.png" Id="myLogo" />

</BootstrapperApplicationRef>

<WixVariable Id="WixExtbaLicenseUrl" Value="" />
<WixVariable Id="WixExtbaThemeXml" Value="Resources\MyTheme.xml" />
<WixVariable Id="WixExtbaThemeWxl" Value="Resources\MyTheme.wxl" />

<util:RegistrySearch Root="HKCU"
Key="Software\AnythingToCheck"
Value="Test" Variable="InstalledDotNet4" />

<Chain>
<MsiPackage Id="dotNETv4" DisplayName="My .NET v4 prerequisite"
SourceFile="myApp.msi"
Visible="yes"
InstallCondition="CheckboxDotNetv4" />
</Chain>
</Wix>

我的主题.xml:
<?xml version="1.0" encoding="utf-8"?>
<Theme xmlns="http://wixtoolset.org/schemas/thmutil/2010">
<!-- Window definition -->
<!-- Font definition -->

<Page Name="Install">
<Checkbox Name="CheckboxDotNet4"
X="205" Y="126"
Width="-100" Height="17"
TabStop="yes" FontId="3"
HideWhenDisabled="yes">.NET Framework 4.0</Checkbox>
<Text Name="InstalledDotNet4"
X="-10" Y="126"
Width="80" Height="17"
TabStop="no" FontId="3"
HideWhenDisabled="yes">(Installed)</Text>
</Page>

<!-- More pages -->
</Theme>

此外,我尝试在 Bundle.wxs 中使用以下代码,但该代码未链接到 RegistrySearch :
<Variable Name="InstalledDotNet4State" Type="string" Value="disable" />

最佳答案

是的,经过广泛研究,我发现可以隐藏 Text基于 RegistrySearch .首先,您需要从 http://wixextba.codeplex.com/ 下载 WiX 扩展 bootstrap 应用程序.提取内容并将 WixBalExtensionExt.dll 添加到您的项目中如Bundle10.wxs所示例如。

然后,打开项目bafunctions文件夹下 Template bafunctions .您需要编译这个 C++ 库并将其作为 Payload 添加到您的包中。 (以 Bundle10.wxs 为例)。

然后,为了能够读取和隐藏 Text控制、取消注释功能 OnDetectComplete()并添加以下代码,例如:

STDMETHODIMP OnDetectComplete()
{
HRESULT hr = S_OK;
LPWSTR sczValue = NULL;

#if DEBUG
// Show log info during debug.
// May not be THE way to log.
size_t i;
LPSTR sczValue2 = (char *) malloc(100);
#endif

BalGetStringVariable(L"InstalledDotNet4Reg", &sczValue);
BalExitOnFailure(hr, "Failed to get variable.");

if (sczValue == NULL)
{
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD,
"Failed to read null variable.");
}
else
{
if (_wtoi(sczValue))
{
hr = m_pEngine->SetVariableString(L"CheckboxDotNetv4State",
L"disable");
BalExitOnFailure(hr, "Failed to set control state.");
hr = m_pEngine->SetVariableNumeric(L"CheckboxDotNetv4", 0);
BalExitOnFailure(hr, "Failed to set variable.");
}
else
{
#if DEBUG
// Log information
wcstombs_s(&i, sczValue2, (size_t)100, sczValue, (size_t)100);
BalLog(BOOTSTRAPPER_LOG_LEVEL_STANDARD, sczValue2);
#endif
hr = m_pEngine->SetVariableString(L"InstalledDotNet4State",
L"disable");
BalExitOnFailure(hr, "Failed to set control state.");
}
}

LExit:
ReleaseStr(sczValue);

return hr;
}

最后,更改(或添加)您的 RegistrySearch ,这样:

<util:RegistrySearch Root="HKLM"
Key="SOFTWARE\Classes\Installer\Products\FCDAC0A0AD874C333A05DC1548B97920"
Variable="InstalledDotNet4Reg" Result="exists" />

关于wix - 在 WiX Bundle 中基于 RegistrySearch 隐藏文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18769338/

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