1
/*******************************************************************************
2
* Copyright (c) 2005, 2009 QNX Software Systems
3
* All rights reserved. This program and the accompanying materials
4
* are made available under the terms of the Eclipse Public License v1.0
5
* which accompanies this distribution, and is available at
6
* http://www.eclipse.org/legal/epl-v10.html
9
* QNX Software Systems - initial API and implementation
10
*******************************************************************************/
14
package org.eclipse.cdt.utils;
16
import org.eclipse.core.runtime.Platform;
20
* @noextend This class is not intended to be subclassed by clients.
21
* @noinstantiate This class is not intended to be instantiated by clients.
23
public class WindowsRegistry {
25
private static boolean failed = false;
26
private static WindowsRegistry registry;
28
private WindowsRegistry() {
31
public static WindowsRegistry getRegistry() {
32
if (registry == null && !failed) {
33
if (Platform.getOS().equals(Platform.OS_WIN32)) {
35
System.loadLibrary("winreg"); //$NON-NLS-1$
36
registry = new WindowsRegistry();
37
} catch (UnsatisfiedLinkError e) {
49
* Gets the registry value for the subkey of HKEY_LOCAL_MACHINE with the
50
* given name. If problems occur, like the name is not found, null is returned.
52
* @param subkey subkey of HKEY_LOCAL_MACHINE
53
* @param name name of the registry value
54
* @return registry value or null if not found
56
public native String getLocalMachineValue(String subkey, String name);
59
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
60
* to the key's array of values, return the name of the indexed value.
61
* The return value is null on any error or when the index is invalid.
62
* The value name can be used in the above getLocalMachineValue() to retrieve
64
* @param subkey subkey of HKEY_LOCAL_MACHINE
65
* @param index index to the subkey's array of values, starting from 0.
66
* @return name of registry value or null if not found
68
public native String getLocalMachineValueName(String subkey, int index);
71
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
72
* to the key's array of sub keys, return the name of the indexed key.
73
* The return value is null on any error or when the index is invalid.
74
* The key name can be used in the above getLocalMachineValueName()
75
* to retrieve value names.
76
* @param subkey subkey of HKEY_CURRENT_USER
77
* @param index index to the subkey's array of values, starting from 0.
78
* @return name of registry value or null if not found
80
public native String getLocalMachineKeyName(String subkey, int index);
83
* Gets the registry value for the subkey of HKEY_CURRENT_USER with the
84
* given name. If problems occur, like the name is not found, null is returned.
86
* @param subkey subkey of HKEY_CURRENT_USER
87
* @param name name of the registry value
88
* @return registry value or null if not found
90
public native String getCurrentUserValue(String subkey, String name);
93
* Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0)
94
* to the key's array of values, return the name of the indexed value.
95
* The return value is null on any error or when the index is invalid.
96
* The value name can be used in the above getCurrentUserValue() to retrieve
98
* @param subkey subkey of HKEY_CURRENT_USER
99
* @param index index to the subkey's array of values, starting from 0.
100
* @return name of registry value or null if not found
102
public native String getCurrentUserValueName(String subkey, int index);
105
* Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0)
106
* to the key's array of sub keys, return the name of the indexed key.
107
* The return value is null on any error or when the index is invalid.
108
* The key name can be used in the above getCurrentUserValueName()
109
* to retrieve value names.
110
* @param subkey subkey of HKEY_CURRENT_USER
111
* @param index index to the subkey's array of values, starting from 0.
112
* @return name of registry value or null if not found
114
public native String getCurrentUserKeyName(String subkey, int index);