简体   繁体   English

从64位Java应用程序访问32位COM DLL(找不到注册表项)

[英]Accessing a 32-bit COM DLL from a 64-bit Java Application (Registry Entry Not Found)

I'm trying to call CoCreateInstance(...) via a 64-bit Java library: org.eclipse.swt.internal.ole.win32.COM. 我试图通过64位Java库调用CoCreateInstance(...):org.eclipse.swt.internal.ole.win32.COM。 The DLL I'm trying to hook into is a DLL for Visual SourceSafe. 我试图挂钩的DLL是Visual SourceSafe的DLL。 The point of the project is to port a VSS plugin (http://sourceforge.net/projects/vssplugin/) made for 32-bit Eclipse to 64-bit Eclipse. 该项目的目的是将为32位Eclipse制作的VSS插件(http://sourceforge.net/projects/vssplugin/)移植到64位Eclipse。

The call works fine when I use the 64-bit version of org.eclipse.swt.internal.ole.win32.COM, but with the 32-bit version, the call fails. 当我使用64位版本的org.eclipse.swt.internal.ole.win32.COM时,调用工作正常,但是对于32位版本,调用失败。 The call is being used like this: 呼叫正在使用如下:

private void init(GUID guid) {
    long[] ppv = new long[1];
    int result = COM.CoCreateInstance(guid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER | COM.CLSCTX_LOCAL_SERVER,
            COM.IIDIDispatch, ppv);
    if (result != COM.S_OK)
        OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
    init(new OleAutomation(new IDispatch(ppv[0])));
}

The call fails and returns -2147221164, which I guess is some kind of error code specifying that the corresponding registry entry can't be found. 调用失败并返回-2147221164,我猜这是某种错误代码,指定无法找到相应的注册表项。

Some things I've tried include: 我尝试过的一些事情包括:

Does anyone have advice on this? 有没有人对此提出建议?

CoCreateInstance is just going to call LoadLibraryEx, and that can't load 32-bit libs in a 64-bit process. CoCreateInstance只是调用LoadLibraryEx,并且无法在64位进程中加载​​32位库。 Period, ever. 期间,永远。 You could, on the other hand: 另一方面,你可以:

  1. obtain a legitimate 64-bit copy of the com component. 获取com组件的合法64位副本。
  2. create your own not-in-process COM server that in turn calls the one you've got, and call CoCreateInstance for the ID of that. 创建您自己的进程内COM服务器,然后调用您已获得的服务器,并调用CoCreateInstance作为其ID。
  3. Create a web service that wraps this thing and use java to call that. 创建一个包装此东西并使用java来调用它的Web服务。
  4. go back to a 32-bit Eclipse. 回到32位Eclipse。

If the COM DLL is automation compatible you just need to set DllSurrogate registry entry. 如果COM DLL是自动兼容的,您只需要设置DllSurrogate注册表项。 COM subsystem will start 32-bit DllHost.exe that will serve as an out-proc COM server for your 64-bit process. COM子系统将启动32位DllHost.exe,它将作为64位进程的out-proc COM服务器。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM