2017-10-17 158 views
1

我对理解WiX安装程序的操作顺序有疑问。
当试图创建一个注册表项添加一个菜单项到Windows资源管理器的上下文菜单,同时使用CustomActions 注册表项将而不是被添加。
但是,如果我只是尝试注册键,它的作品(任何CustomAction代码被注释掉)。同时使用CustomActions时,WiX安装程序创建注册表项不起作用

  1. 在我Product.wxs我已升高特权时与
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated"/>

  2. 在我的<Feature>我有 <ComponentRef Id="RegistryEntries"/>引用。

  3. 这是一个用于创建注册表项

    <Fragment> 
         <Directory Id="TARGETDIR" Name="SourceDir"> 
         <Component Id="RegistryEntries" Guid="*"> 
          <RegistryKey Root="HKCR" 
             Key="Excel.CSV\shell\Use MyConverter\command" 
             ForceCreateOnInstall="yes" 
             ForceDeleteOnUninstall="yes"> 
          <RegistryValue Type="string" Value="[INSTALLLOCATION]$(var.SolutionName).exe %1" 
              KeyPath="yes"/> 
          </RegistryKey> 
         </Component> 
         <Directory Id="ProgramFilesFolder"> 
          <Directory Id="HSZLG" Name="MyConverter"> 
          <Directory Id="INSTALLLOCATION" Name="$(var.SolutionName)" /> 
          </Directory> 
         </Directory> 
         <!--<Directory Id="ProgramMenuFolder"> 
         <Directory Id="Shortcuts" Name="MyConverter" /> 
         </Directory>--> 
        </Directory> 
        </Fragment> 
    
  4. 现在即时通讯也使用下面的自定义操作代码:

    <CustomAction Id="UnregisterImportFormat" BinaryKey="WixCustomAction" DllEntry="UnregisterImportDefinition" Execute="deferred" Impersonate="no" Return="check" /> 
    <CustomAction Id="PropertiesForUnregisterImportFormat" Property="UnregisterImportFormat" Return="check" 
           Value="app=AB;key=10000P1000" /> 
    

    ,并呼吁他们在<InstallSequence>这样的:

    <InstallExecuteSequence> 
        <Custom Action="PropertiesForRegisterImportFormat" Before="RegisterImportFormat" /> 
        <Custom Action="RegisterImportFormat" Before="InstallFinalize">(NOT Installed) OR REINSTALL</Custom> 
    
        <Custom Action="PropertiesForUnregisterImportFormat" Before="UnregisterImportFormat" /> 
        <Custom Action="UnregisterImportFormat" Before="InstallFinalize">REMOVE</Custom> 
    </InstallExecuteSequence> 
    

如果有人能指出我在这里做错了,我会很高兴感激。

+0

这是我的必读书目:http://www.installsite.org/pages/en/isnews/200108/index.htm –

回答

0

由于HKCR不是一个实际的注册表位置,它是交互式用户和HKEY_LOCAL_MACHINE \ Software \ Classes的合并,因此在没有模拟的情况下运行的(延迟的)自定义操作以及HKCR键存在困难。该进入细节:

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

和自定义操作代码与系统帐户下运行(延迟,无模拟),这是将要创建哪些注册表键更加混乱。作为MSDN注云:

“要更改设置为交互式用户,存储在HKEY_CURRENT_USER \ Software \ Classes下的变化,而不是HKEY_CLASSES_ROOT”

,我以为你的代码试图使用HKCR。 Windows Installer是写入这些注册表项的首选,因为它“正常工作”。使用系统帐户写入HKCR的代码是不可靠的,所以如果你真的必须使用代码(并且你不应该),那么试试HKEY_LOCAL_MACHINE \ Software \ Classes。

相关问题