C:int sum(double value,double &rtn)
{
    rtn = value + 1;
    return 1;
}
JNA怎样才能得到rtn的值呢?

解决方案 »

  1.   

    用com.sun.jna.ptr包下面的一些类:
    import com.sun.jna.Library;
    import com.sun.jna.Native;
    import com.sun.jna.ptr.DoubleByReference;public class JNATest { public interface CLibrary extends Library {
    CLibrary INSTANCE = (CLibrary) Native.loadLibrary("test.dll", CLibrary.class); double sum(double value, DoubleByReference rtn);
    }

    public static void main(String[] args){
    DoubleByReference dbr = new DoubleByReference();
    double value = CLibrary.INSTANCE.sum(100,dbr);


    System.out.println("Sum: "+value+", Ref: "+dbr.getValue());
    }
    }
      

  2.   


    谢谢.可以了,现在又有新的问题了.我需要的方法是在DLL中的一个otherOne一个类中的testfun方法.#pragma once
    class otherOne
    {
    public:
    otherOne(void);
    ~otherOne(void);
    int testfun(double&,double&);
    };#include "StdAfx.h"
    #include "otherOne.h"
    otherOne::otherOne(void)
    {
    }
    otherOne::~otherOne(void)
    {
    }
    int otherOne::testfun(double &a,double &b)
    {
    a = a + a;
    b = a + b;
    return 1;
    }怎样才能找到testfun的方法呢??
      

  3.   

    话说我只有DLL,没有lib,只知道方法名字,和参数,1个参数类型也不清楚,哎...