• <bdo id='COmc2'></bdo><ul id='COmc2'></ul>

  • <small id='COmc2'></small><noframes id='COmc2'>

    <legend id='COmc2'><style id='COmc2'><dir id='COmc2'><q id='COmc2'></q></dir></style></legend>
      <tfoot id='COmc2'></tfoot>
      <i id='COmc2'><tr id='COmc2'><dt id='COmc2'><q id='COmc2'><span id='COmc2'><b id='COmc2'><form id='COmc2'><ins id='COmc2'></ins><ul id='COmc2'></ul><sub id='COmc2'></sub></form><legend id='COmc2'></legend><bdo id='COmc2'><pre id='COmc2'><center id='COmc2'></center></pre></bdo></b><th id='COmc2'></th></span></q></dt></tr></i><div id='COmc2'><tfoot id='COmc2'></tfoot><dl id='COmc2'><fieldset id='COmc2'></fieldset></dl></div>

        使用 Com4j 或 Jacob 连接 64 位 Java 和 32 位 COM dll

        时间:2023-09-26
            <tfoot id='8uCr7'></tfoot>

                <small id='8uCr7'></small><noframes id='8uCr7'>

              • <i id='8uCr7'><tr id='8uCr7'><dt id='8uCr7'><q id='8uCr7'><span id='8uCr7'><b id='8uCr7'><form id='8uCr7'><ins id='8uCr7'></ins><ul id='8uCr7'></ul><sub id='8uCr7'></sub></form><legend id='8uCr7'></legend><bdo id='8uCr7'><pre id='8uCr7'><center id='8uCr7'></center></pre></bdo></b><th id='8uCr7'></th></span></q></dt></tr></i><div id='8uCr7'><tfoot id='8uCr7'></tfoot><dl id='8uCr7'><fieldset id='8uCr7'></fieldset></dl></div>
                  <tbody id='8uCr7'></tbody>
                  <bdo id='8uCr7'></bdo><ul id='8uCr7'></ul>

                • <legend id='8uCr7'><style id='8uCr7'><dir id='8uCr7'><q id='8uCr7'></q></dir></style></legend>
                • 本文介绍了使用 Com4j 或 Jacob 连接 64 位 Java 和 32 位 COM dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有以下配置:

                  1) Windows 10 64 位

                  1) Windows 10 64-bit

                  2) 只有 32 位版本且可通过 COM 获得的应用程序.

                  2) An application that has only a 32-bit version and is available through COM.

                  我使用 tlbimb.jar 访问 32 位应用程序的 .dll 文件以生成所需的接口,我成功了.

                  I access the .dll file of the 32-bit application using the tlbimb.jar to generate the interfaces needed and I succeed.

                  场景 1:我尝试使用 Java 8 32-bit 安装访问 32 位应用程序.我可以通过 COM 调用方法成功没有任何问题.

                  Scenario 1: I try to access the 32-bit application using the Java 8 32-bit installation. I can invoke the methods through COM succesfully without any problem.

                  场景 2:我尝试使用 Java 8 64 位安装访问 32 位应用程序.我收到一条错误消息:

                  Scenario 2: I try to access the 32-bit application using a Java 8 64-bit installation. I get an error message:

                  Exception in thread "main" com4j.ExecutionException: com4j.ComException: 80040154 CoCreateInstance failed : Class not registered : .com4j.cpp:153
                  

                  我在 Stackoverflow/Google 上搜索了异常,我做了以下操作:

                  I searched for the exceptin on Stackoverflow/Google and I have done the following:

                  1) 使用 Sys64WOW/regsvr32.exe 和 System32/regsvr32.exe 注册应用程序的 dll

                  1) Registered the application's dll using both Sys64WOW/regsvr32.exe and the System32/regsvr32.exe

                  2) 使用 Sys64WOW/regsvr32.exe 和 System32/regsvr32.exe 注册 com4j dll(32 位和 64 位)

                  2) Registered the com4j dll (both 32 and 64 bit) using both Sys64WOW/regsvr32.exe and the System32/regsvr32.exe

                  3) 复制 Sys64WOW 和 System32 文件夹中的 dll.

                  3) Copied the dlls in the Sys64WOW and System32 folders.

                  我已经分别完成了以上所有操作,检查了所有可能的组合.上述使用 64 位 Java 的错误仍然存​​在.

                  I have done all the above separatelly, checking all the possible combinations. The afortementioned error using 64-bit Java still exists.

                  我尝试过使用另一个网桥(Jacob).在 32 位 Java 上成功,在 64 位 Java 上失败.

                  I have tried using another bridge (Jacob). On 32-bit Java it succeeds, on 64-bit Java it fails.

                  我有一个问题想问可能知道的人:有什么方法可以连接一个应用程序,据我所知,该应用程序仅提供 Win32 COM dll[1],使用任何可用的 Java/COM 桥和 Java 64bit?还是只是 32 位 COM + 64 位 Java 无法连接?

                  I have a question for someone that might knows: Is there any way to connect an app that, as far as I can tell, offers only a Win32 COM dll[1], using any of the available Java/COM bridges and Java 64bit? Or simply 32-bit COM + 64-bit Java are not connectable?

                  [1]:我检查了 OLE/COM 查看器,在类型库下只有一个条目 "0 Win32 = ,所以我暗示这意味着没有 Win64 COM dll,对吧?

                  [1]: I checked the OLE/COM Viewer and under the Type Library there's is only one entry "0 Win32 = , so I implied that this means there's no Win64 COM dll, right?

                  推荐答案

                  这不起作用,因为您的客户端进程和 COM DLL 的位数不匹配.在尝试创建新实例时,CoCreateInstance 会尝试在注册表的 64 位配置单元中查找相关的类信息.这会失败,因为它实际上位于您注册 DLL 的 32 位配置单元中.

                  This won't work because the bitness of your client process and COM DLL don't match. When trying to create a new instance, CoCreateInstance tries to find related class information in the 64-bit hive of the registry. This fails because its actually located in the 32-bit hive, where you registered the DLL.

                  要解决这个问题,您可以选择使用代理进程,它允许您的 CoClass 在不同的本地进程中实例化.然后,您的客户可以通过 IPC 与代理进行通信(请参阅 这里了解更多信息).

                  To remedy this, you have the option of using a surrogate process, which allows your CoClass to be instantiated in a distinct native process. Your client can then communicate with the surrogate via IPC (see here for further info).

                  作为快速入门,您可以将您的 CoClass 标记为默认 dllhost.exe 代理进程的候选者:OLE/COM Object Viewer (x86) as Admin > All Objects > [Your CoClass]> 实施 > 使用代理过程(将路径留空).

                  As a quick start, you can mark your CoClass as a candidate for the default dllhost.exe surrogate process: OLE/COM Object Viewer (x86) as Admin > All Objects > [Your CoClass] > Implementation > Use Surrogate Process (leave path empty).

                  如果您打算分发您的应用程序,您可以将此信息放在 REG 脚本中或将您的 DLL 导入 COM+ 服务器应用程序.

                  If you intend to distribute your application, you may place this information in a REG script or import your DLL into a COM+ server application.

                  这篇关于使用 Com4j 或 Jacob 连接 64 位 Java 和 32 位 COM dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:JACOB 没有正确释放对象 下一篇:java-COM interop:用Java实现COM接口

                  相关文章

                  最新文章

                  1. <small id='Zk5EG'></small><noframes id='Zk5EG'>

                  2. <legend id='Zk5EG'><style id='Zk5EG'><dir id='Zk5EG'><q id='Zk5EG'></q></dir></style></legend>
                      <bdo id='Zk5EG'></bdo><ul id='Zk5EG'></ul>
                    1. <tfoot id='Zk5EG'></tfoot>
                      <i id='Zk5EG'><tr id='Zk5EG'><dt id='Zk5EG'><q id='Zk5EG'><span id='Zk5EG'><b id='Zk5EG'><form id='Zk5EG'><ins id='Zk5EG'></ins><ul id='Zk5EG'></ul><sub id='Zk5EG'></sub></form><legend id='Zk5EG'></legend><bdo id='Zk5EG'><pre id='Zk5EG'><center id='Zk5EG'></center></pre></bdo></b><th id='Zk5EG'></th></span></q></dt></tr></i><div id='Zk5EG'><tfoot id='Zk5EG'></tfoot><dl id='Zk5EG'><fieldset id='Zk5EG'></fieldset></dl></div>