JAVA中如何调用VC的OCX?最好能有个例子!!!!
解决方案 »
- 如果我的tomcat挂掉了或被关闭,我想记录它的时间如何实现?
- 一道基础的文件写操作题
- 一天学会J2SE
- 将获取到的文本框的值写入到文件
- 请教如何生成象JTable那样的表格线,有没有一种布局管理器设一下就可以,使列表数据(里面加了不确定的控件)象Jsp那样表格显示
- 有没有人玩连连看?讨论一下java算法
- 关于中文编码的问题
- jdk-7u51-windows-x64环境变量设置问题
- 只能进不能退,为什么??真是没天理啊.
- java画十个矩形放在一个大矩形内,这十个矩形不能重叠,不能越界,该如何实现
- jcreator 中出现 java.lang.NoClassDefFoundError不知如何解决,在线等
- 50分求奇怪问题,为什么jframe里面不显示东西?在线等
然后利用ms的jvm进行编译即可引用(用了@com指令)think in java 的附录A里有,非常详细
可以试试COM-Java的桥接!
如J-Integra,支持COM和Java组件的双向通信而且不需要本机库!
另外可以关注一下J2EE的COM桥(好像是叫CAS吧)!
你想用JNI实现一遍,几乎是不可能完成的任务。
对象的控制、方法的控制、事件的控制、GUI控制,复杂的很。
我自己用JNI实现了对托盘的控制,感觉就够复杂的了。(除了Windows API外,不同Windows版本的兼容性还的考虑,累),对Com的完整控制就更复杂多了。
听masse的吧,看看第三方的东西,会有收获。
at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
at org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:201)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:587)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:555)
at test3._DGisSeat.OcxTest(_DGisSeat.java:231)
at test3.Test.<init>(Test.java:38)
at test3.Test.main(Test.java:45)
Exception in thread "main"
调用过的两个类:/*
* 创建日期 2005-8-1
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package test3;import org.jawin.COMException;
import org.jawin.DispatchPtr;/**
* @author user
*
* TODO 要更改此生成的类型注释的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class Test
{
public Test() throws COMException
{
_DGisSeat d = new _DGisSeat();
short i = d.OcxTest();
System.out.println( i + " iiiiii");
}
public static void main( String []args) throws COMException
{
Test t = new Test();
}
}package test3;import org.jawin.*;import org.jawin.constants.*;import org.jawin.marshal.*;import org.jawin.io.*;import java.io.*;import java.util.Date;/** * Jawin generated code please do not edit * * Dispatch: _DGisSeat * Description: Dispatch interface for GisSeat Control * Help file: C:\WINNT\system32\GisSeat.hlp * * @author JawinTypeBrowser */public class _DGisSeat extends DispatchPtr { public static final GUID DIID = new GUID("{854de4f8-61da-4465-93A9-23E9734351F8}"); public static final int IID_TOKEN; static { IID_TOKEN = IdentityManager.registerProxy(DIID, _DGisSeat.class); } /** * The required public no arg constructor. * <br><br> * <b>Important:</b>Should never be used as this creates an uninitialized * _DGisSeat (it is required by Jawin for some internal working though). */ public _DGisSeat() { super(); } /** * For creating a new COM-object with the given progid and with * the _DGisSeat interface. * * @param progid the progid of the COM-object to create. */ public _DGisSeat(String progid) throws COMException { super(progid, DIID); } /** * For creating a new COM-object with the given clsid and with * the _DGisSeat interface. * * @param clsid the GUID of the COM-object to create. */ public _DGisSeat(GUID clsid) throws COMException { super(clsid, DIID); } /** * For getting the _DGisSeat interface on an existing COM-object. * This is an alternative to calling {@link #queryInterface(Class)} * on comObject. * * @param comObject the COM-object to get the _DGisSeat interface on. */ public _DGisSeat(COMPtr comObject) throws COMException { super(comObject); } public int getIIDToken() { return IID_TOKEN; } /** * * @return int **/ public int InitSocket() throws COMException { return ((Integer)invokeN("InitSocket", new Object[] {})).intValue(); } /** * * @param strSendInfo * @return int **/ public int SendInfo(String strSendInfo) throws COMException { return ((Integer)invokeN("SendInfo", new Object[] {strSendInfo})).intValue(); } /** * * @return int **/ public int CloseSocket() throws COMException { return ((Integer)invokeN("CloseSocket", new Object[] {})).intValue(); } /** * * @return short **/ public short OcxTest() throws COMException { return ((Short)invokeN("OcxTest", new Object[] {})).shortValue(); } /** * * @return void **/ public void AboutBox() throws COMException { invokeN("AboutBox", new Object[] {}); }}