商城首页欢迎来到中国正版软件门户

您的位置:首页 > 软件教程 >解决JAVA调用DLL的困扰

解决JAVA调用DLL的困扰

  发布于2025-02-03 阅读(0)

扫一扫,手机访问

关于JAVA调用DLL问题

关于JAVA调用DLL问题

MYaction(myinfo);

大体流程就是这样;如果用到本体,则用到这个方法

}

调用的时候,先初始化:

MYinfo.ByReference myinfo = new MYinfo.ByReference();//这就是你要作为参数传进去的变量

调用:

MYInterface.INSTANCE。。。。用java写一个MYinfo的类

public static class MYinfo extends Structure {

public byte[] sType = new byte[16];

public int nVersion;

public static class ByReference extends FACTORY_INFO

implements Structure.ByReference{}//如果作为参数,则用到这个方法

public static class ByValue extends FACTORY_INFO

implements Structure.ByValue{}//

如何在JNI中使用String类型

在NDK中自带了一个最简单的sample,从JNI返回一个string给Java,是这么用的:

#include

#include

/* This is a trivial JNI example where we use a native method

* to return a new VM String. See the corresponding Java source

* file located at:

*

* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java

*/

jstring

Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,

jobject thiz )

{

return (*env)->NewStringUTF(env, "Hello from JNI !");

}

本文转载于:https://www.docexcel.net/show/24_142995.html 如有侵犯,请联系admin@zhengruan.com删除

热门关注