Java JNI 类类型参数如何传递?
我现在用JAVA写一个程序调用现有VB编写test.dll.因为test.dll不符合JNI编写规范,所以在中间还必须编写一个VC++编写的jtest.dll.
一部分函数已经能够成功调用,举个例子说明:
typedef bool (_stdcall *WOCRInit)(int iOcrType,int iHZtype,int iCharacterSet, int res1 );
JNIEXPORT jboolean JNICALL Java_DLLBean_WOcrInit(JNIEnv *env, jclass obj, jint iOcrType, jint iHZtype, jint iCharacterSet, jint res1)
{
HINSTANCE hTest;
WOCRInit wocrInit;
bool bo;
hTest=LoadLibrary("OcrWencui.dll");
wocrInit =(WOCRInit)GetProcAddress(hTest,"WOcrInit");
bo = wocrInit(iOcrType,iHZtype,iCharacterSet,res1);//调用
return bo;
}
提问:
public native static boolean WOcrStart(int Bitmap,Rectangle Rect);//Rectangle为四边形类
这个函数中的Rectangle Rect参数如何传递?
如何实现:
typedef bool (_stdcall *WOcrStart)(……)中的参数列表
WOcrStart(……)中的参数列表
test.dll关于这两个函数的接口定义为
VC: extern "C" BOOL _stdcall EXPORT WOcrStart (HBITMAP Bitmap, RECT* Rect);
请高手明释,谢谢
一部分函数已经能够成功调用,举个例子说明:
typedef bool (_stdcall *WOCRInit)(int iOcrType,int iHZtype,int iCharacterSet, int res1 );
JNIEXPORT jboolean JNICALL Java_DLLBean_WOcrInit(JNIEnv *env, jclass obj, jint iOcrType, jint iHZtype, jint iCharacterSet, jint res1)
{
HINSTANCE hTest;
WOCRInit wocrInit;
bool bo;
hTest=LoadLibrary("OcrWencui.dll");
wocrInit =(WOCRInit)GetProcAddress(hTest,"WOcrInit");
bo = wocrInit(iOcrType,iHZtype,iCharacterSet,res1);//调用
return bo;
}
提问:
public native static boolean WOcrStart(int Bitmap,Rectangle Rect);//Rectangle为四边形类
这个函数中的Rectangle Rect参数如何传递?
如何实现:
typedef bool (_stdcall *WOcrStart)(……)中的参数列表
WOcrStart(……)中的参数列表
test.dll关于这两个函数的接口定义为
VC: extern "C" BOOL _stdcall EXPORT WOcrStart (HBITMAP Bitmap, RECT* Rect);
请高手明释,谢谢
...全文
相关推荐
Jni中C++和Java的参数传递
在JNI中,我们可以使用C++或C语言编写本地方法,这些本地方法可以直接访问和操作Java对象,包括传递参数和接收返回值。在涉及到C++和Java之间的参数传递时,有一些特定的规则和技巧需要注意。
JNI 传递和返回基本参数
该项目演示了Java Native Interface(JNI)中如何实现基本数据类型的参数传递与返回。通过C/C++ native代码与Java层交互,展示了JNIEnv接口的使用、基本类型映射及函
java jni 传递结构体
文档里描述了如何通过jni方法在java与c++代码之间传递非基本类型数据
jni java传递对象到C
**声明JNI函数**:在C/C++头文件中,我们需要声明一个JNI函数,该函数接受`JNIEnv`指针(提供访问Java虚拟机和Java对象的方法)以及`jobject`参数。
JNI学习二:字符串参数传递与返回值
在本示例中,我们关注的是JNI中的字符串参数传递和返回值处理,这对于那些需要在Java和C/C++之间进行深度集成的项目非常重要。1.


Java SE
