• 主页
  • Java SE
  • J2ME
  • Web开发
  • Java EE
  • Eclipse

Jacob调用ocx出现类型不匹配

sinall 2015-03-11 08:06:56
用ActiveXplorer看ocx

Public Function getConnectionState(errorCode As Long) As Long ' 方法getConnectionState


调用代码为:

ActiveXComponent activeX = new ActiveXComponent("XXXCOMCtrl.1");
dispatch = activeX.getObject();
Long errorCode = 0L;
Variant ret = Dispatch.call(dispatch, "getConnectionState", errorCode);


错误为:

Exception in thread "main" com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: getConnectionState
Description: 80020005 / 类型不匹配。

at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.callN(Dispatch.java:453)
at com.jacob.com.Dispatch.call(Dispatch.java:541)
at com.xxx.main(Main.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)


请问该如何调用该函数?
...全文
95 点赞 收藏 1
写回复
1 条回复
clever101 2015年03月26日
改为:

 Long errorCode = 0L;
Variant v = new Variant(errorCode );
 Variant ret = Dispatch.call(dispatch, "getConnectionState", v);
回复 点赞
发动态
发帖子
Java
创建于2007-09-28

1.8w+

社区成员

8.1w+

社区内容

Java相关技术讨论
社区公告
暂无公告