当前位置:编程学习 > JAVA >>

java中怎么用jna调用ocx控件

有看过这样http://lengjing.iteye.com/blog/956750帖子,我试一下还是不行,不知哪位高手做过这样的例子指导一二

我的邮箱1600172177@qq.com

谢谢了 --------------------编程问答-------------------- 有问题就贴具体问题。没人会闲的没事干主动写一篇没稿费教程给你投稿。 --------------------编程问答-------------------- java中怎么用jna调用ocx控件 问题这就是
--------------------编程问答-------------------- --------------------编程问答-------------------- java中怎么用jna调用ocx控件 问题这就是
--------------------编程问答-------------------- --------------------编程问答-------------------- --------------------编程问答-------------------- dll就会调用
ocx还没试过。。。  
不知道行不行,给楼主瞧瞧


package com.powersi;


import org.xvolks.jnative.JNative;
import org.xvolks.jnative.Type;

public class TestJavaInvokeDll {

public static void main(String[] args)throws Exception {
   //系统加载dll文件有两种写法1.loadLibrary方法:把dll文件拷贝到c:\windows\system32目录下,引用时只需写dll名字2.load方法:写dll文件的完整路径
   System.loadLibrary("DataInte");//InterfaceFun是dll文件
   //参数说明InterfaceFun dll名,AddZhiYe函数名
   JNative jnative1 = new JNative("DataInte","newinterface");
   //设置此函数的返回值
   jnative1.setRetVal(Type.LONG);
   //函数执行
   jnative1.invoke();
   //打印函数返回值
   Integer serialNum = Integer.parseInt(jnative1.getRetVal());
   System.out.println(serialNum);
   
   JNative jnative2 = new JNative("DataInte","init");
   //设置此函数的返回值
   jnative2.setRetVal(Type.LONG);
   int i=0;
   //赋予参数值
   jnative2.setParameter(i++, Type.LONG,serialNum+"");
   jnative2.setParameter(i++, Type.STRING,"127.0.0.1");
   jnative2.setParameter(i++, Type.STRING,"8080");
   jnative2.setParameter(i++, Type.STRING,"pis/DataInte");
   //函数执行
   jnative2.invoke();
   //打印函数返回值
   System.out.println(Integer.parseInt(jnative2.getRetVal()));
   
   
}

}

其中init函数的描述:
long init(Interface *p_inter, char *Addr, int Port, char *Servlet)
初始化接口。参数p_inter为函数newinterface()或者newinterfacewithinit的返回值,参数Addr为应用服务器IP地址,Port为应用服务器端口号,Servlet为应用服务器入口Servlet的名称。返回-1表示没有Start成功,返回1表示调用成功。
--------------------编程问答-------------------- newinterface函数描述:
该函数建立一个新的接口实例并将接口初始化,不需要再调用init函数。参数Addr为应用服务器IP地址,Port为应用服务器端口号,Servlet为应用服务器入口Servlet的名称,此函数返回接口指针p_inter,它将作为其他函数入口参数。 --------------------编程问答--------------------
补充:Java ,  Java相关
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,