簡體   English   中英

Wix安裝程序根據用戶輸入創建注冊表項

[英]Wix installer creating registry entry based on user input

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

代碼的主要部分在這里,首先是此屬性。 以后應將其寫入注冊表。

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

稍后有自定義窗口。

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

正確

這是正確的,因為您指定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的實際值永遠不會改變。 它應該始終是對另一個屬性引用,因為您將其與Indirect = Yes一起使用。

問題的可能根本原因

在下一部分中,您為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

因此,基本上我要解決此問題的原因是,我在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)" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM