2015-12-15 37 views
1

因此,基本上我所擁有的是Wix安裝程序,它已被修改,並且目前我的註冊表項存在問題。安裝過程中,安裝程序會有一個自定義對話框,用戶必須選擇/插入第二條路徑。哪些將被存儲在註冊表中。但不是插入用戶輸入的內容,而是插入「[INSTALLFOLDER]」,雖然它應該看起來像「C:\ Program Files ...」。我做了一些研究,但沒有找到任何可以幫助我的東西。 所有的代碼都在同一個文件中。Wix安裝程序根據用戶輸入創建註冊表項

代碼的主要部分在這裏,首先是這個屬性。以後應該寫入註冊表。

​​

後來就有了自定義窗口。低於

<!-- NetWork path --> 
    <Dialog Id="CustomNETDirDlg" Width="370" Height="270" Title="Custom Folder"> 
    <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="!(loc.WixUINext)" /> 
    <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="!(loc.WixUIBack)" /> 
    <Control Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="!(loc.WixUICancel)"> 
     <Publish Event="SpawnDialog" Value="CancelDlg">1</Publish> 
    </Control> 
    <Control Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes" Text="Choose Network Path" /> 
    <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes" Text="NetWork Path" /> 
    <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="!(loc.InstallDirDlgBannerBitmap)" /> 
    <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" /> 
    <Control Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" /> 
    <Control Id="FolderLabel" Type="Text" X="20" Y="60" Width="290" Height="30" NoPrefix="yes" Text="Choose/Enter Path" /> 
    <Control Id="NETFOLDER" Type="Edit" X="20" Y="100" Width="320" Height="18" Text="{200}" Property="CUSTOMPATH" Indirect="yes"/> 
    <Control Id="CustomChangeFolder" Type="PushButton" X="20" Y="120" Width="56" Height="17" Text="!(loc.InstallDirDlgChange)" /> 
    </Dialog> 
    <!--/NetWork path --> 

點點這部分發布...

<Publish Dialog="CustomNETDirDlg" Control="Back" Event="NewDialog" Value="InstallDirDlg">1</Publish> 
    <Publish Dialog="CustomNETDirDlg" Control="Next" Event="NewDialog" Value="VerifyReadyDlg" Order="4">1</Publish> 
    <Publish Dialog="CustomNETDirDlg" Control="CustomChangeFolder" Property="_BrowseProperty" Value="[CUSTOMPATH]" Order="1">1</Publish> 
    <Publish Dialog="CustomNETDirDlg" Control="CustomChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish> 

這對我的作品。 我用「原因」替換了guid。註冊表路徑和其他一切似乎都沒有問題,只是有一件事不起作用,將[CUSTOMPATH]屬性添加爲註冊表值。我也嘗試不使用[]括號,依此類推......甚至嘗試使用[Manufacturer]完美無瑕,將製造商插入註冊表。但是,這裏不起作用。

<DirectoryRef Id="TARGETDIR"> 
    <Component Id="RegistryEntries" Guid="{my guid}"> 
     <RegistryValue Root='HKMU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='[CUSTOMPATH]' KeyPath='yes' /> 
    </Component> 
</DirectoryRef> 

回答

1

正確

,因爲你指定CUSTOMPATH的內容實際上是參考不同的屬性(或目錄,因爲某一點目錄元素成爲提供給像屬性元素中使用)這是正確的:

<Property Id="CUSTOMPATH" Value="INSTALLFOLDER" Secure="yes" /> 
<Control Id="NETFOLDER" Type="Edit" X="20" Y="100" Width="320" Height="18" Text="{200}" Property="CUSTOMPATH" Indirect="yes"/> 

上面將顯示INSTALLFOLDER的內容,因此沒關係。 但是,CUSTOMPATH的實際值永遠不會改變。它應該始終保持對另一個屬性的引用,因爲您將它與間接=是一起使用。您的問題

在接下來的部分

可能的根本原因,你分配一個值CUSTOMPATH而這也正是我覺得不順心的事。我嘗試了以下,它給了我所要求的結果(註冊表值中的「C:\ Program Files ...」)。

<Publish Dialog="CustomNETDirDlg" Control="CustomChangeFolder" Property="_BrowseProperty" Value="[INSTALLFOLDER]" Order="1">1</Publish> 
<RegistryValue Root='HKLM' Key='Software\Test\TestRegEntry1' Type='string' Value='[INSTALLFOLDER]' KeyPath='yes'/> 

如果這不起作用,你可以提供我的日誌文件嗎?

zzz.msi /lvoicewarmupx debug.log 
+0

感謝它幫助我前進。 –

+0

不客氣。請在這種情況下注意/接受答案。 – Starceaker

1

所以基本上我所做的解決這個問題的方法是我在INSTALLFOLDER旁邊創建了另一個目錄。由於我沒有添加任何文件,因此該文件夾將不會被創建,但值仍然存在。

<Directory Id="INSTALLFOLDER2" Name="!(bind.property.ProductName)"></Directory>     
<Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)"> 
    <!-- Here are files I wanted to include --> 
</Directory> 

註冊表項,現在看起來是這樣的:

<DirectoryRef Id="TARGETDIR"> 
    <Component Id="RegistryEntries" Guid="here comes your guid"> 
     <RegistryValue Root='HKMU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value="[INSTALLFOLDER2]" KeyPath='yes' /> 
    </Component> 
</DirectoryRef> 

及性能是這樣的:

<Property Id="CUSTOMPATH" Value="INSTALLFOLDER2" Secure="yes" /> 

文件夾選擇控制這個樣子,這樣既打字和按鈕(文件夾選擇)工作。使用它們的對話框與InstallDirDlg完全相同,但名稱不同。

<Control Id="NETFOLDER" Type="Edit" X="20" Y="100" Width="320" Height="18" Text="{200}" Property="CUSTOMPATH" Indirect="yes" /> 
<Control Id="CustomChangeFolder" Type="PushButton" X="20" Y="120" Width="56" Height="17" Text="!(loc.InstallDirDlgChange)" /> 
相關問題