⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 globalreflibrary.cpp

📁 < Professional Java,JDK 5 Edition> 经典例程源代码。
💻 CPP
字号:
// GlobalRefLibrary.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "..\GlobalRefExample.h"

JNIEXPORT void JNICALL Java_GlobalRefExample_testGlobalRef
  (JNIEnv *env, jobject obj)
{
    static jstring globalString = NULL;
    const char *gStr;

    if(globalString == NULL) {
        // First time through, create global reference
        jstring localStr;

        localStr = env->NewStringUTF("This is a string");

        if(localStr == NULL) {
            return;
        }

        printf("Global reference does not exist, creating...\n");
        globalString = (jstring)env->NewGlobalRef(localStr);
    }

    gStr = env->GetStringUTFChars(globalString, NULL);

    printf("The contents of globalString: %s\n", gStr);
    fflush(stdout);

    env->ReleaseStringUTFChars(globalString, gStr);
}

BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
    return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -