简体   繁体   English

如果用户同意对话框,Wix安装程序如何创建注册表项?

[英]Wix Installer how do I create registry key if the user agrees to a dialog?

I am creating an installer in Wix. 我正在Wix中创建安装程序。 I need a simple dialog during the installation where the user has to agree something, if they do, I want to create a registry key recording this choice. 在安装过程中,我需要一个简单的对话框,在该对话框中,用户必须同意某些事项,如果他们同意,我想创建一个记录此选择的注册表项。

This seems the simplest of tasks, but how do I use Wix to create the dialog and conditionally create the registry key based on the user's input? 这似乎是最简单的任务,但是如何使用Wix创建对话框并根据用户输入有条件地创建注册表项?

So far I've tried to find out about custom actions, but it seems that this is not the right tool as Wix contains the ability to create a registry key already. 到目前为止,我已经尝试找出有关自定义操作的方法,但是似乎这不是正确的工具,因为Wix已包含创建注册表项的功能。 I just don't know how to tie installation of a feature to the response to a specific dialog. 我只是不知道如何将功能的安装与对特定对话框的响应联系起来。 If the agreement is not given, then the installer should continue as normal, just without this specific registry key. 如果未给出协议,则安装程序应继续正常运行,只是没有此特定的注册表项。

I'm using Visual Studio. 我正在使用Visual Studio。

Some code snippets: This is at the top of my product, next to the other properties. 一些代码片段:这是我产品的顶部,其他属性旁边。

<Property Id="STREAMING_ACCEPTED" Secure="yes"/>

Then I have a dialog with the following control element. 然后,我有一个带有以下控件元素的对话框。

<Control Id="StreamingAcceptedCheckBox" Type="CheckBox" X="20" Y="207" Width="330" Height="18" CheckBoxValue="1" Property="STREAMING_ACCEPTED" Text="Accept streaming" />

And finally, I'm trying to hook this up by adding a condition to the component. 最后,我试图通过在组件中添加条件来实现这一点。

<Component Id ="StreamingAcceptanceRegKey" Guid="some-guid" Win64="yes">
  <Condition>STREAMING_ACCEPTED</Condition>
  <RegistryKey Root="HKLM" Key="SOFTWARE\MyProgram" ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
    <RegistryValue Type="string" Name="UsageStats" Value="true" Action="write" KeyPath="yes"/>
  </RegistryKey>
</Component>

Am I on the right lines, because it's not writing the registry key? 我是否正确,因为它没有写注册表项? Does this actually record "true" and "false" to the property based on the checkbox state? 这实际上是否会根据复选框状态在属性中记录“ true”和“ false”?

The UI control has a property associated with it. UI控件具有与其关联的属性。 Make sure it's a secure custom public property. 确保它是安全的自定义公共财产。 (All caps and marked secure ). (所有帽子均已标记为安全)。

Describing how feature selection and INSTALLLEVEL works in an MSI takes some time. 描述功能选择和INSTALLLEVEL在MSI中的工作方式需要一些时间。 Since you only have 1 registry value I would instead suggest creating a component to set the registry value and putting a condition on that component that uses the secure custom public property found in the UI. 由于您只有1个注册表值,因此我建议创建一个组件来设置注册表值,并在该组件上使用在UI中找到的安全自定义公共属性来设置条件。

If you want to support the user going into Programs and Features and changing the original choice then make sure you mark the component as transitive and implement a WiX remember property pattern so that subsequent repairs / transactions keep the choice. 如果要支持用户进入“程序和功能”并更改原始选择,请确保将组件标记为可传递的,并实施WiX记住的属性模式,以便以后的维修/交易保留选择。

http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/ http://robmensching.com/blog/posts/2010/5/2/the-wix-toolsets-remember-property-pattern/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM