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)
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)
1.用swing创建一个界面然后通过jni或者comfyj等一些组件将ocx加载到界面上
2.用vc++创建一个dll,dll内部用cwinapp线程加载一个界面,上面嵌入ocx,然后用dll接口封装ocx功能