dll接口如下,为了让函数清晰,减少了很多相同类型的参数: Dll名称:VoucherVerify.dll 。 函数接口: 
BOOL  __stdcall  VoucherVerify( 
int nMode, 
const char* szAccount, 
cosnt char* szMoney, 
char szRet[65], 
char szExtData[65] 
) ; 参数说明: 
Int nMode   【In】模式。传入1、2、3 
cosnt char* szMoney   【In】交易金额。15位不包含空格小数点。 
例如 :1234.56元, 
则为“000000000123456” 
char szRet[65];   【Out】返回值, 目前只用第一位,其他保留 
szRet[0]  为‘1’ 验票成功。 
szRet[0]  为‘2’ 验票失败。 
char  szExtData [65]   【In/Out】说明数据。 
JNA参考资料,不会的可以一起研究
http://blog.csdn.net/shendl/archive/2008/12/23/3589676.aspx 
http://www.infoxa.com/asp/tech_file/xxnr_tech_793.htm 网络不方便 
要去其他地方办公 
粗略的看了下资料确实不错 
提前问一下两个问题 
用JNA 
char[]类型和函数返回值怎么解决 我拿好资料去研究了,晚上回来 
麻烦熟悉的大侠们指导一下另外一贴在
http://topic.csdn.net/u/20090410/15/c253e6d4-a250-480e-a7c0-e409c453515a.html?seed=1163445911这个是小号,那边发言太多了
一起结分

解决方案 »

  1.   

    char* 的用string
    char[] string 和byte都试过了
    调用dll,界面会出来,但是会地址读取错误(c/c++)常报那个错
    而且我不知道应该怎么处理【out】和【in/out】参数
    贴下测试代码:package com;import com.sun.jna.Native;
    import com.sun.jna.win32.StdCallLibrary;public class MyDll {
    public interface VoucherVerfy extends StdCallLibrary { VoucherVerfy INSTANCE = (VoucherVerfy) Native.loadLibrary(
    "VoucherVerify", VoucherVerfy.class);
    public boolean VoucherVerify(int mode, String opt, String img1,
    String img2, String Zffkrzh, String pzhm, String jyje,
    String cprq, String list, byte[] retvul, byte[] retcode,
    byte[] result, byte[] ext); } public static void main(String[] args) { int mode = 1;
    String opt = "0000";
    String img1 = "d:/1.jpg";
    String img2 = "d:/1.jpg";
    String Zffkrzh = "044036800144006118092001        ";// 付款人帐号 32 不足右补空格
    String pzhm = "000001395607"; // 凭证号码 12 前补0
    String jyje = "000000000004590"; // 交易金额 15 例
    // :1234.56元,则为000000000123456
    String cprq = "20091201"; // 出票日期 8 YYYYMMDD
    String list = "21|大小写金额不符"; byte[] retvul = new byte[65];// 返回值 65【out】
    byte[] retcode = new byte[11];// 退票代码 11【out】
    byte[] result = new byte[65];// 每枚印章的验印结果 65【in/out】
    byte[] ext = new byte[65];// 扩展数据 65【in/out】 boolean success=false;
    try{

    success=VoucherVerfy.INSTANCE.VoucherVerify(mode, opt, img1, img2, Zffkrzh,
    pzhm, jyje, cprq, list, retvul, retcode, result, ext);

    }catch(Exception e){
    e.printStackTrace();
    }finally{
    System.out.println(success);
    }
    }}
      

  2.   

    报错:
    Access violation at address 438ad041 in module 'voucherVerify.dll'. Read of address 00000004
      

  3.   

    可不可以加你qq 我最近也是做java连硬件项目  也遇见和你一样的问题  希望和你一起探讨下 我的qq 85074269
      

  4.   

    官方解答:
    我的一个总结贴会不断更新
    How do I read back a function's string result?Suppose you have a function:
    // Returns the number of characters written to the buffer
    int getString(char* buffer, int bufsize);
    The native code is expecting a fixed-size buffer, which it will fill in with the requested data. A Java String is not appropriate here, since Strings are immutable. Nor is a Java StringBuffer, since the native code only fills the buffer and does not change its size. The appropriate argument type would be either byte[], Memory, or an NIO Buffer, with the size of the object passed as the second argument. The method Native.toString(byte[]) may then be used to convert the array of byte into a Java String.