我在Stack Overflow搜索了几个问题,但没有任何帮助。问题是:
我在注册表中寻找一些价值(我知道该怎么做)。我知道如何设置财产。但是我找不到如何在WiX中编写这个表达式的方法。这就是我想用伪代码编写的内容:
if(registryvalue contains substring1)
set property to value1
if(registryvalue contains substring2)
set property to value2
必须在运行时评估此条件。有没有办法写这个条件?一些示例代码会是什么样的?
答案 0 :(得分:6)
您可以使用type 51 custom action设置属性:
<CustomAction Id="SET_VALUE1" Property="TEST_PROPERTY" Value="value1" />
<CustomAction Id="SET_VALUE2" Property="TEST_PROPERTY" Value="value2" />
在安装顺序中调用自定义操作时使用条件:
<Custom Action="SET_VALUE1" After="AppSearch">Not Installed AND (REG_VALUE="substring1")</Custom>
<Custom Action="SET_VALUE2" After="AppSearch">Not Installed AND (REG_VALUE="substring2")</Custom>
或者您可以在托管代码中编写自定义操作,例如C#,并在 AppSearch 之后安排它,以防您进行多次比较。