2012-11-14 148 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

我已經上傳我的代碼爲最新的代碼,請一次檢查。在這裏,我已經傳遞了值如

相關問題