LPCTSTR AwtTextComponent::GetClassName() { static BOOL richedLibraryLoaded = FALSE; if (!richedLibraryLoaded) { JDK_LoadSystemLibrary("RICHED20.DLL"); richedLibraryLoaded = TRUE; } return RICHEDIT_CLASS; }
/* * Class: sun_awt_shell_Win32ShellFolder2 * Method: getIconResource * Signature: (Ljava/lang/String;IIIZ)J */ JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource (JNIEnv* env, jclass cls, jstring libName, jint iconID, jint cxDesired, jint cyDesired, jboolean useVGAColors) { const char *pLibName = env->GetStringUTFChars(libName, NULL); JNU_CHECK_EXCEPTION_RETURN(env, 0); HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName); if (libHandle != NULL) { UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0; return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID), IMAGE_ICON, cxDesired, cyDesired, fuLoad)); } return 0; }
// Creates a Direct3D9 object and initializes adapters. // If succeeded, returns S_OK, otherwise returns the error code. HRESULT D3DPipelineManager::InitD3D(void) { typedef IDirect3D9 * WINAPI FnDirect3DCreate9(UINT SDKVersion); hLibD3D9 = JDK_LoadSystemLibrary("d3d9.dll"); if (hLibD3D9 == NULL) { J2dRlsTraceLn(J2D_TRACE_ERROR, "InitD3D: no d3d9.dll"); return E_FAIL; } FnDirect3DCreate9 *d3dcreate9 = NULL; d3dcreate9 = (FnDirect3DCreate9*) ::GetProcAddress(hLibD3D9, "Direct3DCreate9"); if (d3dcreate9 == NULL) { J2dRlsTraceLn(J2D_TRACE_ERROR, "InitD3D: no Direct3DCreate9"); ::FreeLibrary(hLibD3D9); return E_FAIL; } pd3d9 = d3dcreate9(D3D_SDK_VERSION); if (pd3d9 == NULL) { J2dRlsTraceLn(J2D_TRACE_ERROR, "InitD3D: unable to create IDirect3D9 object"); ::FreeLibrary(hLibD3D9); return E_FAIL; } HRESULT res; if (FAILED(res = InitAdapters())) { J2dRlsTraceLn(J2D_TRACE_ERROR, "InitD3D: failed to init adapters"); ReleaseD3D(); return res; } return S_OK; }
static BOOL initShellProcs() { static HMODULE libShell32 = NULL; static HMODULE libUser32 = NULL; static HMODULE libComCtl32 = NULL; // If already initialized, return TRUE if (libShell32 != NULL && libUser32 != NULL) { return TRUE; } // Load libraries libShell32 = JDK_LoadSystemLibrary("shell32.dll"); if (libShell32 == NULL) { return FALSE; } libUser32 = JDK_LoadSystemLibrary("user32.dll"); if (libUser32 == NULL) { return FALSE; } libComCtl32 = JDK_LoadSystemLibrary("comctl32.dll"); if (libComCtl32 == NULL) { return FALSE; } // Set up procs - libComCtl32 fn_ImageList_GetIcon = (ImageList_GetIconType)GetProcAddress(libComCtl32, "ImageList_GetIcon"); if (fn_ImageList_GetIcon == NULL) { return FALSE; } // Set up procs - libShell32 fn_FindExecutable = (FindExecutableType)GetProcAddress( libShell32, "FindExecutableW"); if (fn_FindExecutable == NULL) { return FALSE; } fn_SHGetDesktopFolder = (SHGetDesktopFolderType)GetProcAddress(libShell32, "SHGetDesktopFolder"); if (fn_SHGetDesktopFolder == NULL) { return FALSE; } fn_SHGetFileInfo = (SHGetFileInfoType)GetProcAddress( libShell32, "SHGetFileInfoW"); if (fn_SHGetFileInfo == NULL) { return FALSE; } fn_SHGetMalloc = (SHGetMallocType)GetProcAddress(libShell32, "SHGetMalloc"); if (fn_SHGetMalloc == NULL) { return FALSE; } // Set up IMalloc if (fn_SHGetMalloc(&pMalloc) != S_OK) { return FALSE; } fn_SHGetPathFromIDList = (SHGetPathFromIDListType)GetProcAddress( libShell32, "SHGetPathFromIDListW"); if (fn_SHGetPathFromIDList == NULL) { return FALSE; } fn_SHGetSpecialFolderLocation = (SHGetSpecialFolderLocationType) GetProcAddress(libShell32, "SHGetSpecialFolderLocation"); if (fn_SHGetSpecialFolderLocation == NULL) { return FALSE; } // Set up procs - libUser32 fn_GetIconInfo = (GetIconInfoType)GetProcAddress(libUser32, "GetIconInfo"); if (fn_GetIconInfo == NULL) { return FALSE; } fn_DestroyIcon = (DestroyIconType)GetProcAddress(libUser32, "DestroyIcon"); if (fn_DestroyIcon == NULL) { return FALSE; } return TRUE; }
BOOL InitThemes() { static HMODULE hModThemes = NULL; hModThemes = JDK_LoadSystemLibrary("UXTHEME.DLL"); DTRACE_PRINTLN1("InitThemes hModThemes = %x\n", hModThemes); if(hModThemes) { DTRACE_PRINTLN("Loaded UxTheme.dll\n"); OpenThemeData = (PFNOPENTHEMEDATA)GetProcAddress(hModThemes, "OpenThemeData"); DrawThemeBackground = (PFNDRAWTHEMEBACKGROUND)GetProcAddress( hModThemes, "DrawThemeBackground"); CloseThemeData = (PFNCLOSETHEMEDATA)GetProcAddress( hModThemes, "CloseThemeData"); DrawThemeText = (PFNDRAWTHEMETEXT)GetProcAddress( hModThemes, "DrawThemeText"); GetThemeBackgroundContentRect = (PFNGETTHEMEBACKGROUNDCONTENTRECT) GetProcAddress(hModThemes, "GetThemeBackgroundContentRect"); GetThemeMargins = (PFNGETTHEMEMARGINS)GetProcAddress( hModThemes, "GetThemeMargins"); IsThemePartDefined = (PFNISTHEMEPARTDEFINED)GetProcAddress( hModThemes, "IsThemePartDefined"); GetThemeBool = (PFNGETTHEMEBOOL)GetProcAddress( hModThemes, "GetThemeBool"); GetThemeSysBool = (PFNGETTHEMESYSBOOL)GetProcAddress(hModThemes, "GetThemeSysBool"); GetThemeColor = (PFNGETTHEMECOLOR)GetProcAddress(hModThemes, "GetThemeColor"); GetThemeEnumValue = (PFNGETTHEMEENUMVALUE)GetProcAddress(hModThemes, "GetThemeEnumValue"); GetThemeInt = (PFNGETTHEMEINT)GetProcAddress(hModThemes, "GetThemeInt"); GetThemePosition = (PFNGETTHEMEPOSITION)GetProcAddress(hModThemes, "GetThemePosition"); GetThemePartSize = (PFNGETTHEMEPARTSIZE)GetProcAddress(hModThemes, "GetThemePartSize"); SetWindowTheme = (PFNSETWINDOWTHEME)GetProcAddress(hModThemes, "SetWindowTheme"); IsThemeBackgroundPartiallyTransparent = (PFNISTHEMEBACKGROUNDPARTIALLYTRANSPARENT)GetProcAddress(hModThemes, "IsThemeBackgroundPartiallyTransparent"); //this function might not exist GetThemeTransitionDuration = (PFNGETTHEMETRANSITIONDURATION)GetProcAddress(hModThemes, "GetThemeTransitionDuration"); if(OpenThemeData && DrawThemeBackground && CloseThemeData && DrawThemeText && GetThemeBackgroundContentRect && GetThemeMargins && IsThemePartDefined && GetThemeBool && GetThemeSysBool && GetThemeColor && GetThemeEnumValue && GetThemeInt && GetThemePartSize && GetThemePosition && SetWindowTheme && IsThemeBackgroundPartiallyTransparent ) { DTRACE_PRINTLN("Loaded function pointers.\n"); // We need to make sure we can load the Theme. This may not be // the case on a WinXP machine with classic mode enabled. HTHEME hTheme = OpenThemeData(AwtToolkit::GetInstance().GetHWnd(), L"Button"); if(hTheme) { DTRACE_PRINTLN("Loaded Theme data.\n"); CloseThemeData(hTheme); return TRUE; } } else { FreeLibrary(hModThemes); hModThemes = NULL; } } return FALSE; }