简体   繁体   English

在64位组件中注册32位COM类

[英]Register 32-Bit COM Class in 64-Bit Component

I have built a ContextMenuHandler for the Windows Explorer shell using SharpShell . 我使用SharpShell为Windows资源管理器shell构建了一个ContextMenuHandler。 The assembly is built for AnyCPU, ie in MSIL, and can therefore run as both 32 bit and 64 bit. 该程序集是为AnyCPU构建的,即在MSIL中构建,因此可以作为32位和64位运行。

I intend to run this on 64 bit windows only, however, 32 bit applications on windows 64 still use the 32 bit version of the shell for open dialogs, etc. 我打算只在64位窗口上运行它,但是,Windows 64上的32位应用程序仍然使用32位版本的shell进行打开对话框等。

I have registered this assembly manually using the regasm tool on both architectures (32 & 64) and it works fine in the 64bit windows explorer. 我已经在两个体系结构(32和64)上使用regasm工具手动注册了此程序集,并且它在64位Windows资源管理器中工作正常。 It also works from file open, and other shell provided dialogs, in 32 bit applications. 它也适用于32位应用程序中的文件打开和其他shell提供的对话框。 This is the intended behavior, great! 这是预期的行为,太棒了!

The problem I have is writing the installation script, I'm using Wix 3.7 and I don't want to use regasm. 我遇到的问题是编写安装脚本,我正在使用Wix 3.7,我不想使用regasm。

The 64 bit component is installed with:- 64位组件安装时: -

<Component Id="cmpMyAssembly64" Directory="INSTALL_TO_HERE"
    Location="local" Win64="yes">
  <File Id="filMyAssembly" KeyPath="yes" Source="mySource.dll"
      Assembly=".net" AssemblyApplication="filMyAssembly"
      ProcessorArchitecture="msil"/>

  <Class Id="01201201-0000-0000-0000-012345670123" Description="My Handler"
         Context="InprocServer32" ThreadingModel="both" ForeignServer="mscoree.dll">
    <ProgId Id="A.ContextHandler" Description="Does something" />
  </Class>

  <RegistryKey Root="HKCR" Key="CLSID\{01201201-0000-0000-0000-012345670123}"
      ForceCreateOnInstall="yes" ForceDeleteOnUninstall="yes">
    <RegistryKey Key="Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}">
      <RegistryValue Value="" Type="string" />
    </RegistryKey>

    <RegistryKey Key="InprocServer32">
      <RegistryKey Key="1.0.0.0">
        <RegistryValue Name="Class" Value="aNamespace.theClass" Type="string" />
        <RegistryValue Name="Assembly" Value="!(bind.assemblyFullName.filMyAssembly)" Type="string" />
        <RegistryValue Name="RuntimeVersion" Value="v4.0.30319" Type="string" />
        <RegistryValue Name="CodeBase" Value="file:///[#filMyAssembly]" Type="string" />
      </RegistryKey>

        <RegistryValue Name="Class" Value="aNamespace.theClass" Type="string" />
        <RegistryValue Name="Assembly" Value="!(bind.assemblyFullName.filMyAssembly)" Type="string" />
        <RegistryValue Name="RuntimeVersion" Value="v4.0.30319" Type="string" />
        <RegistryValue Name="CodeBase" Value="file:///[#filMyAssembly]" Type="string" />
    </RegistryKey>
  </RegistryKey>

  <RegistryValue Root="HKCR" Key="Directory\Background\shellex\ContextMenuHandlers\MyHandler" Value="{guid}" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="Directory\shellex\ContextMenuHandlers\MyHandler" Value="{guid}" Type="string" Action="write" />
  <RegistryValue Root="HKCR" Key="Drive\shellex\ContextMenuHandlers\MyHandler" Value="{guid}" Type="string" Action="write" />
</Component>

The problem I have is with the 32bit version's registration. 我遇到的问题是32位版本的注册。 Because it uses the same assembly I don't want to install the same file twice. 因为它使用相同的程序集,所以我不想两次安装相同的文件。 All I do is create another (32 bit) component and make the necessary registry changes. 我所做的就是创建另一个(32位)组件并进行必要的注册表更改。

<Component Id="cmp32BitVersion" Directory="INSTALL_TO_32"
    Location="local" Win64="no">
  <Class ... just like 64bit
  <RegistryKey ... just like 64bit
</Component>

Now, I assumed that the Win64 yes/no is how windows installer decides which part of the registry to write to. 现在,我假设Win64是/否是Windows安装程序决定写入哪个部分的注册表。 For 64bit components it writes to HKCR..., for the 32 bit component it would write to HKLM\\SOFTWARE\\WOW6432Node\\Classes. 对于64位组件,它写入HKCR ...,对于32位组件,它将写入HKLM \\ SOFTWARE \\ WOW6432Node \\ Classes。 The problem I have is that because both components are using a file reference [#filMyAssembly] I am getting ICE69: Mismatched component reference, warnings. 我遇到的问题是,因为两个组件都使用文件引用[#filMyAssembly]我得到ICE69:不匹配的组件引用,警告。 The code still builds but I would prefer not to get the warnings, people who don't heed warnings should expect trouble. 代码仍然构建,但我不希望得到警告,不注意警告的人应该预料到麻烦。

Anyway, my question is: what is the correct way to register a MSIL assembly for COM in both 64 and 32 bit applications using Wix/Windows Installer? 无论如何,我的问题是:使用Wix / Windows Installer在64位和32位应用程序中为COM注册MSIL程序集的正确方法是什么?

MikeR and nickheppleston at wix-users look like they've found a solution: 来自wix用户的MikeR和nickheppleston看起来已经找到了解决方案:

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/64-bit-and-32-bit-Registry-Keys-in-same-MSI-td4439679.html http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/64-bit-and-32-bit-Registry-Keys-in-same-MSI-td4439679.html

Thanks all who have responded. 谢谢所有回复的人。 I followed MikeR's comments and came up with the following - I found that I had to reference the x64 Architecture variable when defining both the Component and the ComponentRef within the Feature section, as follows: 我按照MikeR的评论提出了以下内容 - 我发现在功能部分中定义Component和ComponentRef时我必须引用x64 Architecture变量,如下所示:

<Component Id="x86LicencingRegistryKeys" Guid="D113AD25-9E80-44E9-80C0-D66828809DBF" Win64="no">


        <RegistryKey Id="x86ValidationCodeRegKey" Root="HKLM" Key="SOFTWARE\Product\Licencing" Action="createAndRemoveOnUninstall">
                <RegistryValue Id="x86ValidationCodeRegValue" Name="ValidationCode" Action="write" Value="BgIAAACkAABSU0ExgAEAAAEAAQD9iAIysvGIxaJcIiENpOVTZbQosafHa9yXlfG0kxSWKJ01Hlfl+I+4ul5LhxoZkLo=" Type="string" />
                <Permission User="Administrators" ChangePermission="yes" GenericAll="yes" />
                <Permission User="CREATOR OWNER" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Power Users" ChangePermission="yes" GenericAll="yes" />
                <Permission User="SYSTEM" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Users" ChangePermission="yes" GenericAll="no" GenericRead="yes" />
        </RegistryKey>



        <RegistryKey Id="x86LicenceKeyRegKey" Root="HKLM" Key="SOFTWARE\Product\Licencing" Action="createAndRemoveOnUninstall">
                <RegistryValue Id="x86LicenceKeyRegValue" Name="LicenceKey" Action="write" Value="" Type="string" />
                <Permission User="Administrators" ChangePermission="yes" GenericAll="yes" />
                <Permission User="CREATOR OWNER" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Power Users" ChangePermission="yes" GenericAll="yes" />
                <Permission User="SYSTEM" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Users" ChangePermission="yes" GenericAll="no" GenericRead="yes" />                               
        </RegistryKey>


</Component>


<?if $(var.Architecture)=x64 ?>

<Component Id="x64LicencingRegistryKeys" Guid="49A15EB4-2DF8-4FF9-83ED-D306F076E232" Win64="yes">


        <RegistryKey Id="x64ValidationCodeRegKey" Root="HKLM" Key="SOFTWARE\Product\Licencing" Action="createAndRemoveOnUninstall">
                <RegistryValue Id="x64ValidationCodeRegValue" Name="ValidationCode" Action="write" Value="BgIAAACkAABSU0ExgAEAAAEAAQD9iAIysvGIxaJcIiENpOVTZbQosafHa9yXlfG0kxSWKJ01Hlfl+I+4ul5LhxoZkLo=" Type="string" />
                <Permission User="Administrators" ChangePermission="yes" GenericAll="yes" />
                <Permission User="CREATOR OWNER" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Power Users" ChangePermission="yes" GenericAll="yes" />
                <Permission User="SYSTEM" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Users" ChangePermission="yes" GenericAll="no" GenericRead="yes" />
        </RegistryKey>



        <RegistryKey Id="x64LicenceKeyRegKey" Root="HKLM" Key="SOFTWARE\Product\Licencing" Action="createAndRemoveOnUninstall">
                <RegistryValue Id="x64LicenceKeyRegValue" Name="LicenceKey" Action="write" Value="" Type="string" />
                <Permission User="Administrators" ChangePermission="yes" GenericAll="yes" />
                <Permission User="CREATOR OWNER" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Power Users" ChangePermission="yes" GenericAll="yes" />
                <Permission User="SYSTEM" ChangePermission="yes" GenericAll="yes" />
                <Permission User="Users" ChangePermission="yes" GenericAll="no" GenericRead="yes" />                               
        </RegistryKey>


</Component>

<?endif ?>


<Feature Id="Complete" Title="TITLE" Description="Complete Package" Display="expand" Level="1" ConfigurableDirectory="INSTALLDIR">
<ComponentRef Id="x86LicencingRegistryKeys" /> 
<?if $(var.Architecture)=x64 ?><ComponentRef Id="x64LicencingRegistryKeys" /><?endif ?> 
</Feature>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 注册32位COM类,以便在没有管理员权限的64位Python中使用 - Register a 32-bit COM class for use in 64-bit Python without Administrator rights 注册用于32位和64位客户端的32位COM服务器(并生成TLB) - Register 32-bit COM server (and generate TLB) for use with 32-bit and 64-bit clients Windows Installer是否可以注册包装在32位组件中的64位Shell扩展? - Is it possible to have Windows Installer register a 64-bit shell extension which is wrapped in a 32-bit Component? 将32位指针传递给64位COM控件 - Passing 32-bit pointer to 64-bit COM control 在具有32位IIS应用程序的64位服务器上运行的32位crypt组件! - 32-bit crypt component running on 64-bit server with 32-bit IIS app! 如何注册32位外向ATL COM服务器以使其可用于64位程序? - How do I register a 32-bit out-proc ATL COM server to make it available from 64-bit programs? 具有32/64位驱动程序的单个32位MSI - Single 32-bit MSI with 32/64-bit drivers 从 32 位 Windows 服务使用 64 位进程外 COM DLL - Using 64-bit out of process COM DLL from 32-bit Windows Serivce 从32位应用程序调用64位COM控件 - Calling 64-bit COM control from 32-bit app 通过64位应用程序使用32位In-proc COM服务器的简单方法是什么? - What are easy ways to use a 32-bit in-proc COM server from 64-bit applications?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM