简体   繁体   English

通过Java在ActiveX控件(.ocx)中发出调用方法

[英]Issue calling method in ActiveX Control (.ocx) via Java

My end goal is to get a JPG from a fingerprint scanner inside my Java application. 我的最终目标是从Java应用程序内部的指纹扫描仪获取JPG。 I don't need to do any recognition or logins. 我不需要任何识别或登录。

I have a Topaz IDGem LCD 1x5 signature pad / fingerprint scanner. 我有一个Topaz IDGem LCD 1x5签名板/指纹扫描仪。 The SDK they provide for the fingerprint scanner part of the device is called SigIDp1 . 他们为设备的指纹扫描仪部分提供的SDK称为SigIDp1 The problem is that it is only available as an ActiveX control. 问题在于它仅可用作ActiveX控件。

I know next to nothing about ActiveX. 我对ActiveX几乎一无所知。 From my research, I seem to need a Java to COM bridge to interact with the ActiveX control through Java. 从我的研究中,我似乎需要一个Java到COM的桥才能通过Java与ActiveX控件进行交互。 The JACOB project seems to be the most well known. JACOB项目似乎是最著名的。 My problem is that I can't seem to make it work with this particular ActiveX control file. 我的问题是我似乎无法使其与该特定ActiveX控件文件一起使用。

My super advanced Java program looks like this: 我的超高级Java程序如下所示:

import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;

public class JacobTest {

    public static void main(String[] args) {

        Dispatch test = new ActiveXComponent("SigIDp.SigIDp1");

        Dispatch.call(test, "CreateJpg");
    }
}

The problem is that when I try to create the new ActiveXComponent object, I get a com.jacob.com.ComFailException: Can't co-create object error. 问题是,当我尝试创建新的ActiveXComponent对象时,出现com.jacob.com.ComFailException: Can't co-create object错误。 According to this page , it looks like this has to do with the .ocx file not being properly registered. 根据此页面 ,这似乎与.ocx文件未正确注册有关。 However, I can't use the referenced .NET tool (ie RegAsm.exe ) to register the control because I get an error saying it's not a valid .NET assembly. 但是,我无法使用引用的.NET工具(即RegAsm.exe )来注册控件,因为我收到一条错误消息,指出它不是有效的.NET程序集。 And, when I use regsvr32.exe to register it, registration seems to succeed, but I still get the can't co-create error (I've tried the regsvr32.exe in System32 and in SysWOW64). 而且,当我使用regsvr32.exe进行注册时,注册似乎成功了,但是仍然出现无法共同创建的错误(我已经在System32和SysWOW64中尝试了regsvr32.exe )。

All that to say, I'm pretty stuck. 这么说,我很受困扰。 I'm open to any suggestion that will help me achieve the end goal, even if it's start over with friendlier hardware (although I'm having trouble finding any fingerprint scanner with a free Java SDK). 我愿意接受任何可以帮助我实现最终目标的建议,即使它是从更友好的硬件开始的(尽管我在使用免费的Java SDK查找任何指纹扫描仪时都遇到了麻烦)。

For anyone else that stumbles upon this: 对于任何偶然发现此问题的人:

It turns out that it was an architecture issue after all. 事实证明,这毕竟是架构问题。 The ActiveX control in question seems to only be available in 32 bit form. 有问题的ActiveX控件似乎仅以32位形式提供。 So, it didn't matter which version of regsvr32.exe I used to try to register it because (as far as I understand) an app running in a 64 bit JRE can't interact with a 32 bit ActiveX control. 因此,我尝试注册哪个版本的regsvr32.exe没有关系,因为(据我了解),在64位JRE中运行的应用程序无法与32位ActiveX控件进行交互。

The "solution" for me was to use a 32 bit JRE for my project. 对我来说,“解决方案”是为我的项目使用32位JRE。 It's not ideal, but at least I'm moving forward now. 这并不理想,但至少我现在正在前进。

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

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