2012-11-14 113 views
1

我是新来创建使用wix工具的MSI安装程序,在这里我有一个查询请帮助我如何解决这个问题。 我的查询是:我已经创建了一个自定义用户界面,在这里我有一个组合框控件,我已经绑定组合框的值动态使用自定义操作方法它工作正常。现在,我想传递的参数(组合框中选择值)自定义操作方法,我不知道如何传递参数。我瞪大眼睛,但我没有得到答案,请帮助我。如何将参数传递给自定义动作方法wix

这里是我的代码

<Binary Id="CustomActions" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll" /> 
<CustomAction Id='Action1' BinaryKey='CustomActions' DllEntry='FillServerInstances' Execute='immediate' Return='check' /> 
<UI> 
    <Dialog Id="CustomWelcomeEulaDlg" Width="600" Height="450" Title="!(loc.WelcomeEulaDlg_Title)"> 
    <Control Id="Bitmap" Type="Bitmap" X="0" Y="44" Width="600" Height="380" TabSkip="no" Text="MainImage" /> 
    <Control Id="Next" Type="PushButton" X="290" Y="430" Width="60" Height="17" Default="yes" Text="Next"> 
     <Publish Event="DoAction" Value="Action1">1</Publish> 
     <Publish Event="NewDialog" Value="LicenseAgreementDlgs"><![CDATA[1]]></Publish> 
     <Publish Event="ReinstallMode" Value="ecmus"><![CDATA[Installed = 1]]></Publish> 
    </Control> 
    <Control Id="Cancel" Type="PushButton" X="350" Y="430" Width="56" Height="17" Cancel="yes" Text="Cancel"> 
     <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish> 
    </Control> 
    <Control Id="Title" Type="Text" X="15" Y="6" Width="300" Height="15" Transparent="yes" NoPrefix="yes"> 
     <Text>[DlgTitleFont]Welcome to the [ProductName] [Wizard]</Text> 
    </Control> 
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="600" Height="0" /> 
    </Dialog> 

最新的代码

<Product Id="22d32870-651b-4eee-a622-27b2daaade8c" Name="Small Business" Language="1033" Version="1.0.0.0" Manufacturer="Small Business Manufacturing" UpgradeCode="01b2dc2f-61f3-4ff0-a0ba-94dd4cb0829d"> 

     <Package InstallerVersion="200" Compressed="yes" /> 

     <Property Id="MSIFASTINSTALL" Value="3" /> 
     <Binary Id="BIN_CustomAction" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll"/> 
     <Binary Id="myAction" SourceFile="D:\WIX Projects\ExampleSetup\CustomAction1\bin\Debug\CustomAction1.CA.dll"/> 
     <UIRef Id="WixUI_CustomMinimal" /> 

     <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" /> 
     <Property Id="FILEPATH" /> 
       <Directory Id="TARGETDIR" Name="SourceDir"> 
       <Directory Id="ProgramFilesFolder"> 
       <Directory Id="INSTALLLOCATION" Name="Small Business Manufacturing"> 
        <Component Id="Component" Guid="af10d5b4-5d25-474f-8360-13b6c0cd7a53"> 
        <File Id="Component" Source="D:\WIX Projects\Small Business Manufacturing\Small Business Manufacturing\bin\Debug\Myproject.exe" Compressed="yes" KeyPath="yes" Checksum="yes" /> 
        </Component> 

      </Directory> 
      </Directory> 
      </Directory> 

       <Feature Id="ProductFeature" Title="Installation Target" Level="1"> 
       <ComponentRef Id="Component" /> 
       </Feature> 
        <InstallExecuteSequence> 
        <Custom Action="myActionId" After="InstallFinalize"></Custom> 
        </InstallExecuteSequence> 
       <CustomAction Id="SetCustomActionDataValue" Return="check" Property="myActionId" Value="AnotherValue=[Sqlinstaces]" /> 
     <UI> 
      <ProgressText Action="RunEXE">Configuring Foo... (this may take a few minutes).</ProgressText> 
     </UI> 

     </Product> 

回答

2

据我所知,你不能传递参数给自定义操作。您可以在Wix中设置一个属性并使用WcaGetProperty来访问该属性。

我用一个列表框这就好比是如此的相似:

<!--This will be populated via the custom action--> 
    <Control Id="ListBoxID" Type="ListBox" Property="COMPORT" Width="80" Height="40" X="80" Y="165" Indirect="no"> 
     <ListBox Property="COMPORT"> 
     </ListBox> 
    </Control> 

在我的C++自定义操作:

hr = WcaGetFormattedProperty(L"COMPORT",&szComport); 
ExitOnFailure(hr, "failed to get Com Port"); 

编辑:

好了,所以我假设你的组合框的东西像这样:

<Control Id="DummyComboBox" Hidden="yes" Type="ComboBox" Sorted="yes" ComboList="yes" Property="DUMMYPROPERTY" X="65" Y="60" Width="150" Height="18"> 
    <ComboBox Property="DUMMYPROPERTY"> 
    </ComboBox> 

确保您的财产被像这样定义(确保大写字母):

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

你不需要自定义操作发送属性的值。所有你需要做的是使用:

LPWSTR dummyText = NULL; 

hr = WcaGetProperty(L"DUMMYPROPERTY", &dummyText); 
ExitOnFailure(hr, "failed to get Dummy Text"); 

这是一个C++的自定义操作不知道你用的是什么,但一个快速谷歌搜索会告诉你相关的代码使用。

+0

嗨感谢您的response.i已经尝试用你的代码,我得到的是只有硬编码values.If我给像值=属性值“VAR = [房产]”自定义方法的价值,但它没有得到值。 –

+0

该物业必须是大写字母'属性=“COMPORT”',请张贴代码,我会看它.. :) –

+0

我已经上传我的代码为最新的代码,请一次检查。在这里,我已经传递了值如

相关问题