@@ -34,38 +34,38 @@ public class WinRegistry {
34
34
static {
35
35
try {
36
36
regOpenKey = userClass .getDeclaredMethod ("WindowsRegOpenKey" ,
37
- new Class []{int .class , byte [].class , int .class });
37
+ new Class []{long .class , byte [].class , int .class });
38
38
regOpenKey .setAccessible (true );
39
39
regCloseKey = userClass .getDeclaredMethod ("WindowsRegCloseKey" ,
40
- new Class []{int .class });
40
+ new Class []{long .class });
41
41
regCloseKey .setAccessible (true );
42
42
regQueryValueEx = userClass .getDeclaredMethod ("WindowsRegQueryValueEx" ,
43
- new Class []{int .class , byte [].class });
43
+ new Class []{long .class , byte [].class });
44
44
regQueryValueEx .setAccessible (true );
45
45
regEnumValue = userClass .getDeclaredMethod ("WindowsRegEnumValue" ,
46
- new Class []{int .class , int .class , int .class });
46
+ new Class []{long .class , int .class , int .class });
47
47
regEnumValue .setAccessible (true );
48
48
regQueryInfoKey = userClass .getDeclaredMethod ("WindowsRegQueryInfoKey1" ,
49
- new Class []{int .class });
49
+ new Class []{long .class });
50
50
regQueryInfoKey .setAccessible (true );
51
51
regEnumKeyEx = userClass .getDeclaredMethod (
52
- "WindowsRegEnumKeyEx" , new Class []{int .class , int .class ,
52
+ "WindowsRegEnumKeyEx" , new Class []{long .class , int .class ,
53
53
int .class });
54
54
regEnumKeyEx .setAccessible (true );
55
55
regCreateKeyEx = userClass .getDeclaredMethod (
56
- "WindowsRegCreateKeyEx" , new Class []{int .class ,
56
+ "WindowsRegCreateKeyEx" , new Class []{long .class ,
57
57
byte [].class });
58
58
regCreateKeyEx .setAccessible (true );
59
59
regSetValueEx = userClass .getDeclaredMethod (
60
- "WindowsRegSetValueEx" , new Class []{int .class ,
60
+ "WindowsRegSetValueEx" , new Class []{long .class ,
61
61
byte [].class , byte [].class });
62
62
regSetValueEx .setAccessible (true );
63
63
regDeleteValue = userClass .getDeclaredMethod (
64
- "WindowsRegDeleteValue" , new Class []{int .class ,
64
+ "WindowsRegDeleteValue" , new Class []{long .class ,
65
65
byte [].class });
66
66
regDeleteValue .setAccessible (true );
67
67
regDeleteKey = userClass .getDeclaredMethod (
68
- "WindowsRegDeleteKey" , new Class []{int .class ,
68
+ "WindowsRegDeleteKey" , new Class []{long .class ,
69
69
byte [].class });
70
70
regDeleteKey .setAccessible (true );
71
71
} catch (Exception e ) {
@@ -155,13 +155,13 @@ public static List<String> readStringSubKeys(int hkey, String key)
155
155
public static void createKey (int hkey , String key )
156
156
throws IllegalArgumentException , IllegalAccessException ,
157
157
InvocationTargetException {
158
- int [] ret ;
158
+ long [] ret ;
159
159
if (hkey == HKEY_LOCAL_MACHINE ) {
160
160
ret = createKey (systemRoot , hkey , key );
161
- regCloseKey .invoke (systemRoot , new Object []{Integer .valueOf (ret [0 ])});
161
+ regCloseKey .invoke (systemRoot , new Object []{Long .valueOf (ret [0 ])});
162
162
} else if (hkey == HKEY_CURRENT_USER ) {
163
163
ret = createKey (userRoot , hkey , key );
164
- regCloseKey .invoke (userRoot , new Object []{Integer .valueOf (ret [0 ])});
164
+ regCloseKey .invoke (userRoot , new Object []{Long .valueOf (ret [0 ])});
165
165
} else {
166
166
throw new IllegalArgumentException ("hkey=" + hkey );
167
167
}
@@ -206,7 +206,7 @@ public static void createKey(int hkey, String key)
206
206
public static void deleteKey (int hkey , String key )
207
207
throws IllegalArgumentException , IllegalAccessException ,
208
208
InvocationTargetException {
209
- int rc = -1 ;
209
+ long rc = -1 ;
210
210
if (hkey == HKEY_LOCAL_MACHINE ) {
211
211
rc = deleteKey (systemRoot , hkey , key );
212
212
} else if (hkey == HKEY_CURRENT_USER ) {
@@ -260,25 +260,25 @@ public static void deleteValue(int hkey, String key, String value)
260
260
return rc ;
261
261
}
262
262
263
- private static int deleteKey (Preferences root , int hkey , String key )
263
+ private static long deleteKey (Preferences root , int hkey , String key )
264
264
throws IllegalArgumentException , IllegalAccessException ,
265
265
InvocationTargetException {
266
- int rc = ((Integer ) regDeleteKey .invoke (root ,
267
- new Object []{new Integer (hkey ), toCstr (key )})).intValue ();
266
+ long rc = ((Long ) regDeleteKey .invoke (root ,
267
+ new Object []{new Long (hkey ), toCstr (key )})).intValue ();
268
268
return rc ; // can REG_NOTFOUND, REG_ACCESSDENIED, REG_SUCCESS
269
269
}
270
270
271
271
private static String readString (Preferences root , int hkey , String key , String value )
272
272
throws IllegalArgumentException , IllegalAccessException ,
273
273
InvocationTargetException {
274
- int [] handles = (int []) regOpenKey .invoke (root , new Object []{
275
- new Integer (hkey ), toCstr (key ), new Integer (KEY_READ )});
274
+ long [] handles = (long []) regOpenKey .invoke (root , new Object []{
275
+ new Long (hkey ), toCstr (key ), new Integer (KEY_READ )});
276
276
if (handles [1 ] != REG_SUCCESS ) {
277
277
return null ;
278
278
}
279
279
byte [] valb = (byte []) regQueryValueEx .invoke (root , new Object []{
280
- new Integer (handles [0 ]), toCstr (value )});
281
- regCloseKey .invoke (root , new Object []{new Integer (handles [0 ])});
280
+ new Long (handles [0 ]), toCstr (value )});
281
+ regCloseKey .invoke (root , new Object []{new Long (handles [0 ])});
282
282
return (valb != null ? new String (valb ).trim () : null );
283
283
}
284
284
@@ -287,24 +287,24 @@ private static String readString(Preferences root, int hkey, String key, String
287
287
throws IllegalArgumentException , IllegalAccessException ,
288
288
InvocationTargetException {
289
289
HashMap <String , String > results = new HashMap <String , String >();
290
- int [] handles = (int []) regOpenKey .invoke (root , new Object []{
291
- new Integer (hkey ), toCstr (key ), Integer .valueOf (KEY_READ )});
290
+ long [] handles = (long []) regOpenKey .invoke (root , new Object []{
291
+ new Long (hkey ), toCstr (key ), Integer .valueOf (KEY_READ )});
292
292
if (handles [1 ] != REG_SUCCESS ) {
293
293
return null ;
294
294
}
295
- int [] info = (int []) regQueryInfoKey .invoke (root ,
296
- new Object []{new Integer (handles [0 ])});
295
+ long [] info = (long []) regQueryInfoKey .invoke (root ,
296
+ new Object []{new Long (handles [0 ])});
297
297
298
- int count = info [0 ]; // count
299
- int maxlen = info [3 ]; // value length max
298
+ long count = info [0 ]; // count
299
+ long maxlen = info [3 ]; // value length max
300
300
for (int index = 0 ; index < count ; index ++) {
301
301
byte [] name = (byte []) regEnumValue .invoke (root , new Object []{
302
- new Integer
303
- (handles [0 ]), new Integer (index ), new Integer (maxlen + 1 )});
302
+ new Long
303
+ (handles [0 ]), new Integer (index ), new Integer ((( Long ) maxlen ). intValue () + 1 )});
304
304
String value = readString (hkey , key , new String (name ));
305
305
results .put (new String (name ).trim (), value );
306
306
}
307
- regCloseKey .invoke (root , new Object []{new Integer (handles [0 ])});
307
+ regCloseKey .invoke (root , new Object []{new Long (handles [0 ])});
308
308
return results ;
309
309
}
310
310
@@ -335,11 +335,11 @@ private static String readString(Preferences root, int hkey, String key, String
335
335
return results ;
336
336
}
337
337
338
- private static int [] createKey (Preferences root , int hkey , String key )
338
+ private static long [] createKey (Preferences root , int hkey , String key )
339
339
throws IllegalArgumentException , IllegalAccessException ,
340
340
InvocationTargetException {
341
- return (int []) regCreateKeyEx .invoke (root ,
342
- new Object []{Integer .valueOf (hkey ), toCstr (key )});
341
+ return (long []) regCreateKeyEx .invoke (root ,
342
+ new Object []{Long .valueOf (hkey ), toCstr (key )});
343
343
}
344
344
345
345
private static void writeStringValue
0 commit comments