这里有个简单的例子 希望对你有所帮助
#include <jni.h>
#include "WinCAClass.h"
#include <stdio.h>
#include <windows.h>
HINSTANCE SafeEngineJava;
JNIEXPORT void JNICALL Java_WinCAClass_SE_1LoadLibrary
(JNIEnv *, jobject)
{
SafeEngineJava=LoadLibrary("SafeEngine.dll");
}
JNIEXPORT void JNICALL Java_WinCAClass_SE_1FreeLibrary
(JNIEnv *, jobject)
{
FreeLibrary(SafeEngineJava);
}
JNIEXPORT jlong JNICALL Java_WinCAClass_SE_1InitialSession
(JNIEnv *env, jobject, jlong x, jstring y, jstring z, jlong o, jlong p, jstring q, jstring r)
{
typedef long (* _SE_InitialSession)(unsigned long privatekeydevicetype,
char *privatekeydeviceparameter, char *privatekeypassword, unsigned long privatekeytimeout,
unsigned long certchaindevicetype, char *certchaindeviceparameter, char *certchainpassword );
_SE_InitialSession SE_InitialSession;
long returnValue;
////////////
char *str = (char *)env->GetStringUTFChars(y, JNI_FALSE );
char *str1 = (char *)env->GetStringUTFChars(z, JNI_FALSE );
char *str2 = (char *)env->GetStringUTFChars(q, JNI_FALSE );
char *str3 = (char *)env->GetStringUTFChars(r, JNI_FALSE );
////////////
SE_InitialSession=(_SE_InitialSession)GetProcAddress(SafeEngineJava,"SE_InitialSession");
returnValue= (*SE_InitialSession)((unsigned long)x,str,str1,(unsigned long)o,(unsigned long)p,str2,str3);
return returnValue;
}