< prev index next >
src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp
Print this page
@@ -121,30 +121,36 @@
#endif
extern "C" {
-static BOOL initShellProcs()
+static BOOL initShellProcs(char*& cause)
{
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");
+ char *name = "shell32.dll";
+ libShell32 = JDK_LoadSystemLibrary(name);
if (libShell32 == NULL) {
+ cause = name;
return FALSE;
}
- libUser32 = JDK_LoadSystemLibrary("user32.dll");
+ name = "user32.dll";
+ libUser32 = JDK_LoadSystemLibrary(name);
if (libUser32 == NULL) {
+ cause = name;
return FALSE;
}
- libComCtl32 = JDK_LoadSystemLibrary("comctl32.dll");
+ name = "comctl32.dll";
+ libComCtl32 = JDK_LoadSystemLibrary(name);
if (libComCtl32 == NULL) {
+ cause = name;
return FALSE;
}
// Set up procs - libComCtl32
fn_ImageList_GetIcon = (ImageList_GetIconType)GetProcAddress(libComCtl32, "ImageList_GetIcon");
@@ -225,12 +231,22 @@
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_sun_awt_shell_Win32ShellFolder2_initIDs
(JNIEnv* env, jclass cls)
{
- if (!initShellProcs()) {
- JNU_ThrowInternalError(env, "Could not initialize shell library");
+ char *cause = NULL;
+ if (!initShellProcs(cause)) {
+ char msg[2048] = "Could not initialize shell library ";
+ if (cause) {
+ strcat(msg + strlen(msg), cause);
+ }
+ if (::GetLastError()) {
+ strcat(msg + strlen(msg), ". ");
+ size_t n = getLastErrorString(msg + strlen(msg), sizeof(msg) -
+ strlen(msg));
+ }
+ JNU_ThrowInternalError(env, msg);
return;
}
MID_pIShellFolder = env->GetMethodID(cls, "setIShellFolder", "(J)V");
CHECK_NULL(MID_pIShellFolder);
FID_pIShellIcon = env->GetFieldID(cls, "pIShellIcon", "J");
< prev index next >