标签:
package cn.ylca.dll;
public class DllEntity {
//本地方法
public native void messagebox();
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class cn_ylca_dll_DllEntity */
#ifndef _Included_cn_ylca_dll_DllEntity
#define _Included_cn_ylca_dll_DllEntity
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: cn_ylca_dll_DllEntity
* Method: messagebox
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_cn_ylca_dll_DllEntity_messagebox
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
// javadll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class cn_ylca_dll_DllEntity */
#ifndef _Included_cn_ylca_dll_DllEntity
#define _Included_cn_ylca_dll_DllEntity
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: cn_ylca_dll_DllEntity
* Method: messagebox
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_cn_ylca_dll_DllEntity_messagebox
(JNIEnv *env, jobject obj){//补上参数名字
//到这里就不许要再说什么的了把!
MessageBox(NULL, "测试!", "demo", 0);
}
#ifdef __cplusplus
}
#endif
#endif
public class Test {
public static void main(String[] args) {
//加载指定路径的dll
System.load("D://javadll//Debug//javadll.dll");
//创建本地方法对象
DllEntity dllEntity = new DllEntity();
//调用方法
dllEntity.messagebox();
}
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5874836.html