多字符串类型的 RegistryValue 元素 [英] RegistryValue Element of type multiString

查看:23
本文介绍了多字符串类型的 RegistryValue 元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WiX

<小时>

只需转储一些示例测试标记 - 疣和所有 :-) - 如果您愿意,可以用于测试:

<RegistryValue Id="R1" Root="HKCU" Key="Software\_WiXTest" KeyPath="yes"Name="WiXWritten" Type="string" Value="R1 常规字符串"></RegistryValue><RegistryValue Id="R2" Root="HKCU" Action="append" Key="Software\_WiXTest"Name="WiXWritten" Type="multiString" Value="R2 sample multistring"><MultiStringValue>test1.1</MultiStringValue><MultiStringValue>test1.2</MultiStringValue><MultiStringValue>test1.3</MultiStringValue></RegistryValue><RegistryValue Id="R3" Root="HKCU" Action="write" Key="Software\_WiXTest"Name="WiXWritten" Type="multiString" Value="R3 sample multistring"><MultiStringValue>test2.1</MultiStringValue><MultiStringValue>test2.2</MultiStringValue></RegistryValue></组件>

上面的一些元素会在安装时相互覆盖——据我所知,这是你不清楚的地方.也许将其转储到您的 WiX 源中并进行测试.

通过重复多个 RegistryValue 元素,您可以获得与 MultiStringValue 元素相同的效果.

尝试将最后一个 RegistryValue 元素的 Action="write" 更改为 Action="append".现在它添加到现有的多字符串而不是覆盖它.它应该变成:R2 sample multistring\0test1.1\0test1.2\0test1.3\0R3 sample multistring\0test2.1\0test2.2\0\0.

The WiX doc says that if type is MultiString then we can specify actions, append, prepend, write(default). what is mean by write action here? does it simply overwrites earlier entry, or adds with semicolon? if it just overwrites earlier entry, how it is different from type "string"

解决方案

I believe write overwrites the existing value(s) whether string or multi string, and enforces whatever new string type is specified. Multi string is different from string because you can add a list of stings via the <MultiStringValue> element (a regular string value can not do this - it cannot have MultiStringValue child elements):

<RegistryValue Id="R3" Root="HKCU" Action="write" Key="Software\_WiXTest"
               Name="multi" Type="multiString" Value="samplemultistring">
    <MultiStringValue>test2.1</MultiStringValue>
    <MultiStringValue>test2.2</MultiStringValue>
</RegistryValue>

For multi string prepend adds the string at the start of the string list and append adds the string to the end of the string list. Multi strings are not semicolon delimited as far as I know, but a sequence of null-terminated strings, terminated by an empty string (\0). See Registry Value Types:

Sample Multi String: String1\0String2\0String3\0LastString\0\0, and how it looks in regedit.exe (with a contrasting regular string):


Just dumping some sample test markup - warts and all :-) - you can use for testing if you'd like:

<Component Feature="MainApplication" Id="HKCU" Guid="*">
  <RegistryValue Id="R1" Root="HKCU" Key="Software\_WiXTest" KeyPath="yes" 
                 Name="WiXWritten" Type="string" Value="R1 regular string">
  </RegistryValue>
  <RegistryValue Id="R2" Root="HKCU" Action="append" Key="Software\_WiXTest" 
                 Name="WiXWritten" Type="multiString" Value="R2 sample multistring">
      <MultiStringValue>test1.1</MultiStringValue>
      <MultiStringValue>test1.2</MultiStringValue>
      <MultiStringValue>test1.3</MultiStringValue>
  </RegistryValue>
  <RegistryValue Id="R3" Root="HKCU" Action="write" Key="Software\_WiXTest"
                 Name="WiXWritten" Type="multiString" Value="R3 sample multistring">
     <MultiStringValue>test2.1</MultiStringValue>
     <MultiStringValue>test2.2</MultiStringValue>
   </RegistryValue>
 </Component>

Some of the elements above will overwrite each other on install - as far as I understand that's what wasn't clear to you. Maybe dump this in your WiX source and give it a test spin.

By repeating several RegistryValue elements you can get the same effect as the MultiStringValue elements.

Try changing the last RegistryValue element's Action="write" to Action="append". Now it adds to the existing multi string instead of overwriting it. It should become: R2 sample multistring\0test1.1\0test1.2\0test1.3\0R3 sample multistring\0test2.1\0test2.2\0\0.

这篇关于多字符串类型的 RegistryValue 元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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