Getting CustomActionData from C++

拥有回忆 提交于 2019-12-25 05:43:40

问题


I have a Wix file where I am creating a Deferred Custom Action. I have written a C# program, which is, for now, looping over the CustomActionData and printing the Key and Values. Consider the snippet given below:

<Binary Id="myAction" SourceFile="..\Type51CA\bin\Release\Type51CA.CA.dll" />
<CustomAction Id="CustomAction1" Property="CustomAction2" Value="SomePropertyOne=[INSTALLFOLDER];SomePropertyTwo=[IPADDRESS];" />
  <CustomAction Id="CustomAction2" BinaryKey="myAction" DllEntry="MyCustomAction" Execute="deferred" Return="check" HideTarget="no" />
<InstallExecuteSequence>
   <Custom Action="CustomAction1" Before="CustomAction2" />
   <Custom Action="CustomAction2" Before="InstallFinalize" />
</InstallExecuteSequence>

I am setting the SomePropertyOne and SomePropertyTwo in CA Id="CustomAction1".

The following C# code can iterate over CustomActionData

session.Log("Begin MyCustomAction");
CustomActionData datas = session.CustomActionData;
foreach (KeyValuePair<String, String> data in datas)
{
   session.Log(String.Format("Key = {0} Value = {1}\n", data.Key, data.Value));
}

Since I want to remove the dependency of .Net, I want to write the equivalent C# code in C++; using WcaGetProperty(L"CustomActionData",&caData) didn't give me any result. In C++, how can I get the required value of a corresponding Key from CustomActionData?


回答1:


CustomActionData can be as simple as you want or as complicated as you want. My favorite is JSON but in reality it doesn't really matter as long as the CA setting the property and the CA decoding the property follow the same spec.



来源:https://stackoverflow.com/questions/31993322/getting-customactiondata-from-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!