日期:2014-05-20  浏览次数:20731 次

java调用C中的方法,采用jna,本人不太清楚怎么将c中的方法在java中如何定义
下面是二个c 的中dll文件接口中提供的二个方法 

int GenerateKeyA(unsigned long AuthenticationCode, unsigned long CardNo, unsigned long SerialNo, unsigned char *KeyBuffer);

int GenerateAuthenticationCode(unsigned short sicCode, unsigned long CardNo, unsigned long SerialNo unsigned long *AuthenticationCode);

想在java中声明, 然后通过 CLibrary.INSTANCE进行调用 
请问我该如何转化方法,不太清楚java与c数据类型应该如何对应

------解决方案--------------------
线在java中写好native方法, 编译后, 在用 javah -jni 编译这个类, 把生成的.h文件拿去实现, 编译成dll
在对应类中加入 System.loadLibrary() 就可以调用了,
------解决方案--------------------
NativeLong long 平台依赖(32 或64 位整数)

JNA有这个类型
java的String对应c的char*