2016-11-17 39 views
1

我正在創建x64 msi。我有一些註冊表值要設置。在Wix中,我使用下面的代碼。註冊表項在Wix中無法正常工作

<Component Id="RegistryEntries1" Guid="{GUID1}" Win64="yes"> 
    <RegistryKey Root="HKLM" 
       Key="Software\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{FF.....}" 
       Action="createAndRemoveOnUninstall"> 
     <RegistryValue Type="string" Value="SomeName" KeyPath="yes"/> 
    </RegistryKey> 
    </Component> 


    <Component Id="RegistryEntries2" Guid="{GUID2}" Win64="yes"> 
    <RegistryKey Root="HKCR" 
        Key="CLSID\{FF.....}" 
        Action="createAndRemoveOnUninstall"> 
     <RegistryValue Type="string" Value="SomeName" KeyPath="yes"/> 
    </RegistryKey> 
    </Component> 


    <Component Id="RegistryEntries3" Guid="{GUID3}" Win64="yes"> 
    <RegistryKey Root="HKCR" 
        Key="CLSID\{{FF.....}\InprocServer32" 
        Action="createAndRemoveOnUninstall"> 
     <RegistryValue Type="string" Value="SomeName.dll" KeyPath="no"/> 
     <RegistryValue Type="string" Name="ThreadingModel" Value="Apartment" KeyPath="yes"/> 
    </RegistryKey> 
    </Component> 

這些值在註冊表中設置,但我的應用程序無法正常工作。

當我使用reg文件設置註冊表值時,應用程序正常工作。

而且我SomeName.dll是在System32中

Windows Registry Editor Version 5.00 

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{FF.....}] 
@="SomeName" 

[HKEY_CLASSES_ROOT\CLSID\{FF.....}] 
@="SomeName" 

[HKEY_CLASSES_ROOT\CLSID\{FF.....}\InprocServer32] 
@="SomeName.dll" 
"ThreadingModel"="Apartment" 

有沒有在我的維克斯代碼中的任何問題。

+0

您的應用程序可能作爲服務運行嗎?或者作爲另一個帳戶運行? – PhilDW

+0

@PhilDW是的。我的應用程序是一個服務安裝程序。 –

回答

2

這個問題很可能是HKCR是一個虛擬鍵,在你的情況下是HKLM \ Software \ Classes和HKCU \ Software \ Classes的合併視圖。這就解釋了它:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms724475(v=vs.85).aspx

所以與本地系統帳戶運行的是沒有看到這些。如果你使用系統帳戶運行註冊表,如果這是發生的事情,你將看不到你的HKCR類。

因此,如果您在HKLM \ Software \ Classes中進行輸入,我認爲您的服務/服務安裝程序代碼會看到它們。 ServiceInstaller類通常以系統帳戶的自定義操作運行。如果您使用的是WiX,則不需要ServiceInstaller類(可能是從Visual Studio設置進行遷移),因爲ServiceInstall和ServiceControl可以完成這項工作。

+0

謝謝....工作... –