标签:end 不能 next util block href 解析 方法 lan
下载地址:
JNative_1.4RC2_src.zip : http://jaist.dl.sourceforge.net/sourceforge/jnative/JNative_1.4RC2_src.zip
JNative.jar : http://nchc.dl.sourceforge.net/sourceforge/jnative/JNative.jar
如果以上版本不能完成下载,说明版本有可能更新,请从以下地址中下载:
Resource URL: http://jnative.sourceforge.net/
Source Code: http://sourceforge.net/projects/jnative
Detailed Review: http://jnative.free.fr
JavaDOC: http://jnative.free.fr/docs/
JNative相对于其它同类开源组件的优点:
1.容易使用
2.对数据类型的处理做的出色
3.支持CallBack
下面以一个小Demo来学习一下JNative:
1.理解文件用途
JNative_1.4RC2_src.zip是JNative源代码的压缩包把它解压后从中找到libJNativeCpp.so和JNativeCpp.dll两个文件.JNativeCpp.dll应用在Windows平台下.把它放在c:\windows\system32目录下.libJNativeCpp.so应用在Linux平台下.放在哪个目录,这个我不知道.
把JNative.jar加入到所需的工程中.
把要调用的dll文件也放在c:\windows\system32目录下, 这个目录存在一个文件,
2.测试类
- package sms;
-
- import org.xvolks.jnative.JNative;
- import org.xvolks.jnative.exceptions.NativeException;
- import org.xvolks.jnative.pointers.Pointer;
- import org.xvolks.jnative.pointers.memory.MemoryBlockFactory;
-
- public class SystemTime extends org.xvolks.jnative.util.Kernel32.SystemTime {
- public short wYear;
- public short wMonth;
- public short wDayOfWeek;
- public short wDay;
- public short wHour;
- public short wMinute;
- public short wSecond;
- public short wMilliseconds;
-
- public Pointer createPointer() throws NativeException {
- pointer = new Pointer(MemoryBlockFactory.createMemoryBlock(getSizeOf()));
- return pointer;
- }
-
-
- public int getSizeOf(){
- return 8 * 2;
- }
-
-
- public SystemTime getValueFromPointer() throws NativeException {
- wYear = getNextShort();
- wMonth = getNextShort();
- wDayOfWeek = getNextShort();
- wDay = getNextShort();
- wHour = getNextShort();
- wMinute = getNextShort();
- wSecond = getNextShort();
- wMilliseconds = getNextShort();
- return this;
- }
-
- public SystemTime() throws NativeException{
- super();
- createPointer();
- }
-
- public String toString(){
- return wYear + "/" + wMonth + "/" + wDay + " at + " + wHour + ":" + wMinute + ":" + wSecond + ":" + wMilliseconds;
- }
-
- public static SystemTime GetSystemTime() throws NativeException, IllegalAccessException {
-
- JNative nGetSystemTime = new JNative("Kernel32.dll", "GetSystemTime");
-
-
- SystemTime systemTime = new SystemTime();
-
- nGetSystemTime.setParameter(0, systemTime.getPointer());
-
- nGetSystemTime.invoke();
-
- return systemTime.getValueFromPointer();
- }
-
- public static void main(String[] args) throws NativeException, IllegalAccessException{
- System.err.println(GetSystemTime());
-
- }
-
- }
jnative 使用
标签:end 不能 next util block href 解析 方法 lan
原文地址:http://www.cnblogs.com/ouyangping/p/7624030.html