【问题标题】:java-Can not access ActiveX application "com.jacob.com.ComFailException: Can't get object clsid from progid"java-无法访问 ActiveX 应用程序“com.jacob.com.ComFailException: Can't get object clsid from progid”
【发布时间】:2019-12-02 15:12:57
【问题描述】:

我正在尝试进行面部检测和比较代码。现在对于这个项目,我将使用 ZZActiveX2.0。 所以我使用 jacob 来访问 Active X。 我下载了 jacob-1.19 并将 jacob-1.19-x86.dll 复制到 System32 并在我的 java 项目中注册了 jacob-1.19.jar。 我检查了注册表中的应用程序 clsid(HKEY_CLASSES_ROOT\ACTIVEX.ActiveXCtrl.1\CLSID(Default)->"{e77e4cc8-e879-4a72-850a-b824742ec5b7}")。

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

class ActiveXTest {
    public static void main(String[] args) {       
        try {
            ActiveXComponent xl = new ActiveXComponent("{e77e4cc8-e879-4a72-850a-b824742ec5b7}");
            Dispatch xlo = xl.getObject();

        }
        catch (Exception e){
            e.printStackTrace();
        }

    }
}

但是这段代码出现如下错误。

com.jacob.com.ComFailException: Can't get object clsid from progid
    at com.jacob.com.Dispatch.createInstanceNative(Native Method)
    at com.jacob.com.Dispatch.<init>(Dispatch.java:99)
    at com.jacob.activeX.ActiveXComponent.<init>(ActiveXComponent.java:58)
    at ActiveXTest.main(ActvieXTest.java:11)

我搜索了这个错误并看到了关于 Word 应用程序的示例项目。 我遵循了一些解决方案,但它在我的项目中不起作用。有人建议使用 regasm 或 AutoItx,但它也不起作用。 你见过这种类型的错误吗?这个问题你解决了吗?

【问题讨论】:

    标签: java activex jacob


    【解决方案1】:

    您必须插入注册程序名称而不是 clsid。

     ActiveXComponent activeXComponent = new ActiveXComponent("ACTIVEX.ActiveXCtrl.1");
    

    【讨论】:

    • 感谢您的帮助。我解决了问题。效果很好
    【解决方案2】:

    您可以使用 CLSID,但语法如下:

    ActiveXComponent xl = new ActiveXComponent("CLSID:{e77e4cc8-e879-4a72-850a-b824742ec5b7}");       
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-10-31
      • 1970-01-01
      • 2014-11-06
      • 2015-12-06
      • 1970-01-01
      • 2021-09-07
      • 1970-01-01
      相关资源
      最近更新 更多