1

我是使用 wix 工具创建 MSI 安装程序的新手,在这里我有一个疑问,请帮助我如何解决这个问题。我的查询是:我创建了一个自定义 UI,在此我有一个组合框控件,并且我使用自定义 Action 方法将组合框值动态绑定,它工作正常。现在,我想将参数(组合框选择的值)传递给自定义操作方法,我不知道如何传递参数。我目瞪口呆,但我没有得到答案,请帮帮我。

这是我的代码

 <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>
4

1 回答 1

3

据我所知,您不能将参数传递给自定义操作。您可以在 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");

编辑:

好的,所以我假设您的 ComboBox 是这样的:

  <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++ 自定义操作,不确定您使用的是什么,但快速的谷歌搜索会告诉您要使用的相关代码。

于 2012-11-14T12:58:21.773 回答