1 | /* |
2 | * $Id: HKEY.java,v 1.7 2006/02/01 04:47:24 hastings Exp $ |
3 | * |
4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
5 | * |
6 | * All Rights Reserved |
7 | * |
8 | * This material may be reproduced by or for the U. S. Government |
9 | * pursuant to the copyright license under the clause at |
10 | * DFARS 252.227-7014 (OCT 2001). |
11 | */ |
12 | |
13 | package com.moesol.bindings.platform_sdk.windows_api; |
14 | |
15 | /** |
16 | * @author Adam |
17 | * |
18 | * To change the template for this generated type comment go to |
19 | * Window>Preferences>Java>Code Generation>Code and Comments |
20 | */ |
21 | public class HKEY extends HANDLE { |
22 | |
23 | // Root Keys |
24 | public static final HKEY CLASSES_ROOT = new HKEY(0x80000000); |
25 | public static final HKEY CURRENT_USER = new HKEY(0x80000001); |
26 | public static final HKEY LOCAL_MACHINE = new HKEY(0x80000002); |
27 | public static final HKEY USERS = new HKEY(0x80000003); |
28 | public static final HKEY PERFORMANCE_DATA = new HKEY(0x80000004); |
29 | // #if(WINVER >= 0x0400) |
30 | public static final HKEY CURRENT_CONFIG = new HKEY(0x80000005); |
31 | public static final HKEY DYN_DATA = new HKEY(0x80000006); |
32 | |
33 | /** |
34 | * @param handle |
35 | * @param temporary |
36 | */ |
37 | public HKEY(long handle, boolean temporary) { |
38 | super(handle, temporary); |
39 | } |
40 | |
41 | /** |
42 | * @param handle |
43 | */ |
44 | public HKEY(long handle) { |
45 | super(handle); |
46 | } |
47 | |
48 | /** |
49 | * Calls {@link PlatformSDK#RegOpenKeyEx}. Similar to ATL's CRegKey.Open. |
50 | * @throws Win32Exception unless ERROR_SUCCESS is returned |
51 | */ |
52 | public static HKEY Open(HKEY hKeyParent, String lpszKeyName, int samDesired) { |
53 | HKEY out_key[] = { null }; |
54 | PlatformSDK.RegOpenKeyEx(hKeyParent, lpszKeyName, 0, samDesired, out_key); |
55 | return out_key[0]; |
56 | } |
57 | |
58 | /** |
59 | * Calls Open with KEY_ALL_ACCESS. |
60 | * @throws Win32Exception unless ERROR_SUCCESS is returned |
61 | */ |
62 | public static HKEY Open(HKEY hKeyParent, String lpszKeyName) { |
63 | return Open(hKeyParent, lpszKeyName, PlatformSDK.KEY_ALL_ACCESS); |
64 | } |
65 | |
66 | /** |
67 | * Calls {@link PlatformSDK#RegCloseKey(HKEY)} |
68 | * @throws Win32Exception unless ERROR_SUCCESS is returned |
69 | */ |
70 | public void Close() { |
71 | PlatformSDK.RegCloseKey(this); |
72 | } |
73 | |
74 | /** |
75 | * Calls {@link PlatformSDK#RegQueryValue(HKEY, String, Object[]) |
76 | * @param string |
77 | * @return |
78 | */ |
79 | public String QueryStringValue(String string) { |
80 | Object[] out_value = { null }; |
81 | PlatformSDK.RegQueryValue(this, string, out_value); |
82 | return (String)out_value[0]; |
83 | } |
84 | } |