OLD | NEW |
| (Empty) |
1 /* | |
2 * Licensed to the Apache Software Foundation (ASF) under one or more | |
3 * contributor license agreements. See the NOTICE file distributed with | |
4 * this work for additional information regarding copyright ownership. | |
5 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
6 * (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * | |
9 * http://www.apache.org/licenses/LICENSE-2.0 | |
10 * | |
11 * Unless required by applicable law or agreed to in writing, software | |
12 * distributed under the License is distributed on an "AS IS" BASIS, | |
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
14 * See the License for the specific language governing permissions and | |
15 * limitations under the License. | |
16 */ | |
17 | |
18 package org.apache.tomcat.jni; | |
19 | |
20 /** Windows Registy support | |
21 * | |
22 * @author Mladen Turk | |
23 */ | |
24 public class Registry { | |
25 | |
26 /* Registry Enums */ | |
27 public static final int HKEY_CLASSES_ROOT = 1; | |
28 public static final int HKEY_CURRENT_CONFIG = 2; | |
29 public static final int HKEY_CURRENT_USER = 3; | |
30 public static final int HKEY_LOCAL_MACHINE = 4; | |
31 public static final int HKEY_USERS = 5; | |
32 | |
33 public static final int KEY_ALL_ACCESS = 0x0001; | |
34 public static final int KEY_CREATE_LINK = 0x0002; | |
35 public static final int KEY_CREATE_SUB_KEY = 0x0004; | |
36 public static final int KEY_ENUMERATE_SUB_KEYS = 0x0008; | |
37 public static final int KEY_EXECUTE = 0x0010; | |
38 public static final int KEY_NOTIFY = 0x0020; | |
39 public static final int KEY_QUERY_VALUE = 0x0040; | |
40 public static final int KEY_READ = 0x0080; | |
41 public static final int KEY_SET_VALUE = 0x0100; | |
42 public static final int KEY_WOW64_64KEY = 0x0200; | |
43 public static final int KEY_WOW64_32KEY = 0x0400; | |
44 public static final int KEY_WRITE = 0x0800; | |
45 | |
46 public static final int REG_BINARY = 1; | |
47 public static final int REG_DWORD = 2; | |
48 public static final int REG_EXPAND_SZ = 3; | |
49 public static final int REG_MULTI_SZ = 4; | |
50 public static final int REG_QWORD = 5; | |
51 public static final int REG_SZ = 6; | |
52 | |
53 /** | |
54 * Create or open a Registry Key. | |
55 * @param name Registry Subkey to open | |
56 * @param root Root key, one of HKEY_* | |
57 * @param sam Access mask that specifies the access rights for the key. | |
58 * @param pool Pool used for native memory allocation | |
59 * @return Opened Registry key | |
60 */ | |
61 public static native long create(int root, String name, int sam, long pool) | |
62 throws Error; | |
63 | |
64 /** | |
65 * Opens the specified Registry Key. | |
66 * @param name Registry Subkey to open | |
67 * @param root Root key, one of HKEY_* | |
68 * @param sam Access mask that specifies the access rights for the key. | |
69 * @param pool Pool used for native memory allocation | |
70 * @return Opened Registry key | |
71 */ | |
72 public static native long open(int root, String name, int sam, long pool) | |
73 throws Error; | |
74 | |
75 /** | |
76 * Close the specified Registry key. | |
77 * @param key The Registry key descriptor to close. | |
78 */ | |
79 public static native int close(long key); | |
80 | |
81 /** | |
82 * Get the Registry key type. | |
83 * @param key The Registry key descriptor to use. | |
84 * @param name The name of the value to query | |
85 * @return Value type or negative error value | |
86 */ | |
87 public static native int getType(long key, String name); | |
88 | |
89 /** | |
90 * Get the Registry value for REG_DWORD | |
91 * @param key The Registry key descriptor to use. | |
92 * @param name The name of the value to query | |
93 * @return Registry key value | |
94 */ | |
95 public static native int getValueI(long key, String name) | |
96 throws Error; | |
97 | |
98 /** | |
99 * Get the Registry value for REG_QWORD or REG_DWORD | |
100 * @param key The Registry key descriptor to use. | |
101 * @param name The name of the value to query | |
102 * @return Registry key value | |
103 */ | |
104 public static native long getValueJ(long key, String name) | |
105 throws Error; | |
106 | |
107 /** | |
108 * Get the Registry key length. | |
109 * @param key The Registry key descriptor to use. | |
110 * @param name The name of the value to query | |
111 * @return Value size or negative error value | |
112 */ | |
113 public static native int getSize(long key, String name); | |
114 | |
115 /** | |
116 * Get the Registry value for REG_SZ or REG_EXPAND_SZ | |
117 * @param key The Registry key descriptor to use. | |
118 * @param name The name of the value to query | |
119 * @return Registry key value | |
120 */ | |
121 public static native String getValueS(long key, String name) | |
122 throws Error; | |
123 | |
124 /** | |
125 * Get the Registry value for REG_MULTI_SZ | |
126 * @param key The Registry key descriptor to use. | |
127 * @param name The name of the value to query | |
128 * @return Registry key value | |
129 */ | |
130 public static native String[] getValueA(long key, String name) | |
131 throws Error; | |
132 | |
133 /** | |
134 * Get the Registry value for REG_BINARY | |
135 * @param key The Registry key descriptor to use. | |
136 * @param name The name of the value to query | |
137 * @return Registry key value | |
138 */ | |
139 public static native byte[] getValueB(long key, String name) | |
140 throws Error; | |
141 | |
142 | |
143 /** | |
144 * Set the Registry value for REG_DWORD | |
145 * @param key The Registry key descriptor to use. | |
146 * @param name The name of the value to set | |
147 * @param val The the value to set | |
148 * @return If the function succeeds, the return value is 0 | |
149 */ | |
150 public static native int setValueI(long key, String name, int val); | |
151 | |
152 /** | |
153 * Set the Registry value for REG_QWORD | |
154 * @param key The Registry key descriptor to use. | |
155 * @param name The name of the value to set | |
156 * @param val The the value to set | |
157 * @return If the function succeeds, the return value is 0 | |
158 */ | |
159 public static native int setValueJ(long key, String name, long val); | |
160 | |
161 /** | |
162 * Set the Registry value for REG_SZ | |
163 * @param key The Registry key descriptor to use. | |
164 * @param name The name of the value to set | |
165 * @param val The the value to set | |
166 * @return If the function succeeds, the return value is 0 | |
167 */ | |
168 public static native int setValueS(long key, String name, String val); | |
169 | |
170 /** | |
171 * Set the Registry value for REG_EXPAND_SZ | |
172 * @param key The Registry key descriptor to use. | |
173 * @param name The name of the value to set | |
174 * @param val The the value to set | |
175 * @return If the function succeeds, the return value is 0 | |
176 */ | |
177 public static native int setValueE(long key, String name, String val); | |
178 | |
179 /** | |
180 * Set the Registry value for REG_MULTI_SZ | |
181 * @param key The Registry key descriptor to use. | |
182 * @param name The name of the value to set | |
183 * @param val The the value to set | |
184 * @return If the function succeeds, the return value is 0 | |
185 */ | |
186 public static native int setValueA(long key, String name, String[] val); | |
187 | |
188 /** | |
189 * Set the Registry value for REG_BINARY | |
190 * @param key The Registry key descriptor to use. | |
191 * @param name The name of the value to set | |
192 * @param val The the value to set | |
193 * @return If the function succeeds, the return value is 0 | |
194 */ | |
195 public static native int setValueB(long key, String name, byte[] val); | |
196 | |
197 /** | |
198 * Enumerate the Registry subkeys | |
199 * @param key The Registry key descriptor to use. | |
200 * @return Array of all subkey names | |
201 */ | |
202 public static native String[] enumKeys(long key) | |
203 throws Error; | |
204 | |
205 /** | |
206 * Enumerate the Registry values | |
207 * @param key The Registry key descriptor to use. | |
208 * @return Array of all value names | |
209 */ | |
210 public static native String[] enumValues(long key) | |
211 throws Error; | |
212 | |
213 /** | |
214 * Delete the Registry value | |
215 * @param key The Registry key descriptor to use. | |
216 * @param name The name of the value to delete | |
217 * @return If the function succeeds, the return value is 0 | |
218 */ | |
219 public static native int deleteValue(long key, String name); | |
220 | |
221 /** | |
222 * Delete the Registry subkey | |
223 * @param root Root key, one of HKEY_* | |
224 * @param name Subkey to delete | |
225 * @param onlyIfEmpty If true will not delete a key if | |
226 * it contains any subkeys or values | |
227 * @return If the function succeeds, the return value is 0 | |
228 */ | |
229 public static native int deleteKey(int root, String name, | |
230 boolean onlyIfEmpty); | |
231 | |
232 | |
233 } | |
OLD | NEW |