1 /* Copyright (c) 2010 Daniel Doubrovkine, All Rights Reserved
2  *
3  * The contents of this file is dual-licensed under 2
4  * alternative Open Source/Free licenses: LGPL 2.1 or later and
5  * Apache License 2.0. (starting with JNA version 4.0.0).
6  *
7  * You can freely decide which license you want to apply to
8  * the project.
9  *
10  * You may obtain a copy of the LGPL License at:
11  *
12  * http://www.gnu.org/licenses/licenses.html
13  *
14  * A copy is also included in the downloadable source code package
15  * containing JNA, in file "LGPL2.1".
16  *
17  * You may obtain a copy of the Apache License at:
18  *
19  * http://www.apache.org/licenses/
20  *
21  * A copy is also included in the downloadable source code package
22  * containing JNA, in file "AL2.0".
23  */
24 package com.sun.jna.platform.win32;
25 
26 import com.sun.jna.Native;
27 import com.sun.jna.Pointer;
28 import com.sun.jna.platform.win32.WinNT.HANDLE;
29 import com.sun.jna.ptr.ByReference;
30 
31 /**
32  * This module contains the function prototypes and constant, type and structure
33  * definitions for the Windows 32-Bit Registry API.
34  * Ported from WinReg.h
35  * Microsoft Windows SDK 6.0A.
36  * @author dblock[at]dblock.org
37  */
38 public interface WinReg {
39 
40     public static class HKEY extends HANDLE {
HKEY()41         public HKEY() { }
HKEY(Pointer p)42         public HKEY(Pointer p) { super(p); }
HKEY(int value)43         public HKEY(int value) { super(new Pointer(value)); }
44     }
45 
46     public static class HKEYByReference extends ByReference {
HKEYByReference()47         public HKEYByReference() {
48             this(null);
49         }
50 
HKEYByReference(HKEY h)51         public HKEYByReference(HKEY h) {
52             super(Native.POINTER_SIZE);
53             setValue(h);
54         }
55 
setValue(HKEY h)56         public void setValue(HKEY h) {
57             getPointer().setPointer(0, h != null ? h.getPointer() : null);
58         }
59 
getValue()60         public HKEY getValue() {
61             Pointer p = getPointer().getPointer(0);
62             if (p == null)
63                 return null;
64             if (WinBase.INVALID_HANDLE_VALUE.getPointer().equals(p))
65                 return (HKEY) WinBase.INVALID_HANDLE_VALUE;
66             HKEY h = new HKEY();
67             h.setPointer(p);
68             return h;
69         }
70     }
71 
72     HKEY HKEY_CLASSES_ROOT = new HKEY(0x80000000);
73     HKEY HKEY_CURRENT_USER = new HKEY(0x80000001);
74     HKEY HKEY_LOCAL_MACHINE = new HKEY(0x80000002);
75     HKEY HKEY_USERS = new HKEY(0x80000003);
76     HKEY HKEY_PERFORMANCE_DATA= new HKEY(0x80000004);
77     HKEY HKEY_PERFORMANCE_TEXT= new HKEY(0x80000050);
78     HKEY HKEY_PERFORMANCE_NLSTEXT = new HKEY(0x80000060);
79     HKEY HKEY_CURRENT_CONFIG  = new HKEY(0x80000005);
80     HKEY HKEY_DYN_DATA = new HKEY(0x80000006);
81 }
82