< prev index next >

src/java.desktop/windows/native/libawt/windows/ShellFolder2.cpp

Print this page
rev 56251 : 8230900: missing ReleaseStringUTFChars in java.desktop native code
   1 /*
   2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1113  */
1114 JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getSystemIcon
1115     (JNIEnv* env, jclass cls, jint iconID)
1116 {
1117     return (jlong)LoadIcon(NULL, MAKEINTRESOURCE(iconID));
1118 }
1119 
1120 
1121 /*
1122  * Class:     sun_awt_shell_Win32ShellFolder2
1123  * Method:    getIconResource
1124  * Signature: (Ljava/lang/String;IIIZ)J
1125  */
1126 JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
1127     (JNIEnv* env, jclass cls, jstring libName, jint iconID,
1128      jint cxDesired, jint cyDesired, jboolean useVGAColors)
1129 {
1130     const char *pLibName = env->GetStringUTFChars(libName, NULL);
1131     JNU_CHECK_EXCEPTION_RETURN(env, 0);
1132     HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName);



1133     if (libHandle != NULL) {
1134         UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
1135         return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID),
1136                                       IMAGE_ICON, cxDesired, cyDesired,
1137                                       fuLoad));
1138     }
1139     return 0;
1140 }
1141 
1142 
1143 /*
1144  * Helper function for creating Java column info object
1145  */
1146 static jobject CreateColumnInfo(JNIEnv *pEnv,
1147                                 jclass *pClass, jmethodID *pConstructor,
1148                                 int colNum, SHELLDETAILS *psd, ULONG visible)
1149 {
1150     jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str));
1151     JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL);
1152 


   1 /*
   2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1113  */
1114 JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getSystemIcon
1115     (JNIEnv* env, jclass cls, jint iconID)
1116 {
1117     return (jlong)LoadIcon(NULL, MAKEINTRESOURCE(iconID));
1118 }
1119 
1120 
1121 /*
1122  * Class:     sun_awt_shell_Win32ShellFolder2
1123  * Method:    getIconResource
1124  * Signature: (Ljava/lang/String;IIIZ)J
1125  */
1126 JNIEXPORT jlong JNICALL Java_sun_awt_shell_Win32ShellFolder2_getIconResource
1127     (JNIEnv* env, jclass cls, jstring libName, jint iconID,
1128      jint cxDesired, jint cyDesired, jboolean useVGAColors)
1129 {
1130     const char *pLibName = env->GetStringUTFChars(libName, NULL);
1131     JNU_CHECK_EXCEPTION_RETURN(env, 0);
1132     HINSTANCE libHandle = (HINSTANCE)JDK_LoadSystemLibrary(pLibName);
1133     if (pLibName != NULL) {
1134         env->ReleaseStringUTFChars(libName, pLibName);
1135     }
1136     if (libHandle != NULL) {
1137         UINT fuLoad = (useVGAColors && !IS_WINXP) ? LR_VGACOLOR : 0;
1138         return ptr_to_jlong(LoadImage(libHandle, MAKEINTRESOURCE(iconID),
1139                                       IMAGE_ICON, cxDesired, cyDesired,
1140                                       fuLoad));
1141     }
1142     return 0;
1143 }
1144 
1145 
1146 /*
1147  * Helper function for creating Java column info object
1148  */
1149 static jobject CreateColumnInfo(JNIEnv *pEnv,
1150                                 jclass *pClass, jmethodID *pConstructor,
1151                                 int colNum, SHELLDETAILS *psd, ULONG visible)
1152 {
1153     jstring str = jstringFromSTRRET(pEnv, NULL, &(psd->str));
1154     JNU_CHECK_EXCEPTION_RETURN(pEnv, NULL);
1155 


< prev index next >