< prev index next >

src/java.prefs/windows/native/libprefs/WindowsPreferences.c

Print this page
rev 12879 : 8136556: Add the ability to perform static builds of MacOSX x64 binaries
Reviewed-by: ihse, bdelsart, gadams, lfoltan, rriggs, hseigel, twisti
   1 /*
   2  * Copyright (c) 2000, 2002, 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
  23  * questions.
  24  */
  25 
  26 #include <stdlib.h>
  27 #include <windows.h>
  28 #include "jni.h"
  29 #include "jni_util.h"
  30 #include "jvm.h"
  31 #ifdef __cplusplus
  32 extern "C" {
  33 #endif






  34     JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey
  35                (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey, jint securityMask) {
  36         HKEY handle;
  37         char* str;
  38         int tmp[2];
  39         int errorCode=-1;
  40         jintArray result;
  41         str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
  42         CHECK_NULL_RETURN(str, NULL);
  43         errorCode =  RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
  44         (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
  45         tmp[0]= (int) handle;
  46         tmp[1]= errorCode;
  47         result = (*env)->NewIntArray(env,2);
  48         if (result != NULL) {
  49             (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
  50         }
  51         return result;
  52     }
  53 


   1 /*
   2  * Copyright (c) 2000, 2015, 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
  23  * questions.
  24  */
  25 
  26 #include <stdlib.h>
  27 #include <windows.h>
  28 #include "jni.h"
  29 #include "jni_util.h"
  30 #include "jvm.h"
  31 #ifdef __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 /*
  36  * Declare library specific JNI_Onload entry if static build
  37  */
  38 DEF_STATIC_JNI_OnLoad
  39 
  40     JNIEXPORT jintArray JNICALL Java_java_util_prefs_WindowsPreferences_WindowsRegOpenKey
  41                (JNIEnv* env, jclass this_class, jint hKey, jbyteArray lpSubKey, jint securityMask) {
  42         HKEY handle;
  43         char* str;
  44         int tmp[2];
  45         int errorCode=-1;
  46         jintArray result;
  47         str = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
  48         CHECK_NULL_RETURN(str, NULL);
  49         errorCode =  RegOpenKeyEx((HKEY)hKey, str, 0, securityMask, &handle);
  50         (*env)->ReleaseByteArrayElements(env, lpSubKey, str, 0);
  51         tmp[0]= (int) handle;
  52         tmp[1]= errorCode;
  53         result = (*env)->NewIntArray(env,2);
  54         if (result != NULL) {
  55             (*env)->SetIntArrayRegion(env, result, 0, 2, tmp);
  56         }
  57         return result;
  58     }
  59 


< prev index next >