main.c
来自「《透视Java》的源码」· C语言 代码 · 共 31 行
C
31 行
/*
* Implementation of native methods that access OS thru Win32 API
*/
#include <windows.h>
#include "covertjava_nativecode_OSMemoryInfo.h"
typedef JNIEXPORT jlong (JNICALL* FuncType) (JNIEnv *, jclass);
int main(char** args)
{
HMODULE hMod = LoadLibrary("OSMemoryInfo.dll");
FuncType pFunc = (FuncType)GetProcAddress(hMod, "_Java_covertjava_nativecode_OSMemoryInfo_getPhysicalTotal@8");
jclass cls;
int total = -1;
if (hMod == 0 || pFunc == 0) {
printf("ERROR: Got hMod = %d, func = %d\n", (int)hMod, (int)pFunc);
return 1;
}
total = pFunc(0, cls);
printf("Total = %d\n", total);
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?