java调用ocx异常问题
com.jacob.com.ComFailException: A COM exception has been encountered:At Invoke of: ConnectToServer
Description: 80010105 / 服务器出现意外情况。
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 test.Test.initTest(Test.java:25)
at test.Test.main(Test.java:63)
现在是调用一个登录方法报错 当你不知道哪里的问题 这个错误描述百度google都搜不到相干问题。
掉其余方法有返回值 就‘ConnectToServer’报如上错误 请高手指教! Java ocx --------------------编程问答-------------------- package test;
import com.jacob.com.*;
import com.jacob.activeX.*;
import java.io.*;
public class Test {
ActiveXComponent comx=new ActiveXComponent("clsid:731B048F-7419-41FB-88C7-F74A852CF09A");
public void initTest()
{
try
{
ComThread.InitSTA(true);
Dispatch ob = (Dispatch)comx.getObject();
Dispatch.call(ob, "ConnectToServer",new Variant("192.168.1.191"),new Variant(1722),new Variant("xxxx"),new Variant("xxxx")).toString();
System.out.println(Dispatch.call(ob,"GetCurUserType").getShort());
ComThread.Release();//释放线程
}catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args){
Test test = new Test();
test.initTest();
}
}
=================================================
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: ConnectToServer
Description: 80010105 / 服务器出现意外情况。
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 test.Test.initTest(Test.java:25)
at test.Test.main(Test.java:63)
--------------------编程问答-------------------- --------------------编程问答-------------------- ??!!... --------------------编程问答-------------------- 之前也遇到类似问题,你的ocx是不是带有界面,如果是的,那么当ConnectToServer调用了界面相关的内容或者这个接口需要在界面初始化完成后才能调用就会出现这样的情况
你有两种选择:
1.用swing创建一个界面然后通过jni或者comfyj等一些组件将ocx加载到界面上
2.用vc++创建一个dll,dll内部用cwinapp线程加载一个界面,上面嵌入ocx,然后用dll接口封装ocx功能
补充:Java , Java SE