blob: 1998c497754245467746e6af410ecb1b1d90ff99 [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2004 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18// -=- Registry.h
19
20// C++ wrappers around the Win32 Registry APIs
21
22#ifndef __RFB_WIN32_REGISTRY_H__
23#define __RFB_WIN32_REGISTRY_H__
24
25#define WIN32_LEAN_AND_MEAN
26#include <windows.h>
27
28#include <rfb_win32/Security.h>
29#include <rfb/util.h>
30
31namespace rfb {
32
33 namespace win32 {
34
35 class RegKey {
36 public:
37 // No key open
38 RegKey();
39
40 // Duplicate the specified existing key
41 RegKey(const HKEY k);
42 RegKey(const RegKey& k);
43
44 // Calls close() internally
45 ~RegKey();
46
47 void setHKEY(HKEY key, bool freeKey);
48 protected:
49 HKEY operator=(const RegKey& k);
50 HKEY operator=(HKEY k);
51 public:
52
53 // Returns true if key was created, false if already existed
54 bool createKey(const RegKey& root, const TCHAR* name);
55
56 // Opens key if it exists, or raises an exception if not
57 void openKey(const RegKey& root, const TCHAR* name, bool readOnly=false);
58
59 // Set the (discretionary) access control list for the key
60 void setDACL(const PACL acl, bool inheritFromParent=true);
61
62 // Closes current key, if required
63 void close();
64
65 // Delete a subkey/value
66 void deleteKey(const TCHAR* name) const;
67 void deleteValue(const TCHAR* name) const;
68
69
70 void awaitChange(bool watchSubTree, DWORD filter) const;
71
72 void setExpandString(const TCHAR* valname, const TCHAR* s) const;
73 void setString(const TCHAR* valname, const TCHAR* s) const;
74 void setBinary(const TCHAR* valname, const void* data, int length) const;
75 void setInt(const TCHAR* valname, int i) const;
76 void setBool(const TCHAR* valname, bool b) const;
77
78 TCHAR* getString(const TCHAR* valname) const;
79 TCHAR* getString(const TCHAR* valname, const TCHAR* def) const;
80
81 void getBinary(const TCHAR* valname, void** data, int* length) const;
82 void getBinary(const TCHAR* valname, void** data, int* length, void* def, int deflength) const;
83
84 int getInt(const TCHAR* valname) const;
85 int getInt(const TCHAR* valname, int def) const;
86
87 bool getBool(const TCHAR* valname) const;
88 bool getBool(const TCHAR* valname, bool def) const;
89
90 TCHAR* getRepresentation(const TCHAR* valname) const;
91
92 bool isValue(const TCHAR* valname) const;
93
94 // Get the name of value number "i"
95 // If there are fewer than "i" values then return 0
96 // NAME IS OWNED BY RegKey OBJECT!
97 const TCHAR* getValueName(int i);
98
99 operator HKEY() const;
100 protected:
101 HKEY key;
102 bool freeKey;
103 TCharArray valueName;
104 DWORD valueNameBufLen;
105 };
106
107 };
108
109};
110
111#endif // __RFB_WIN32_REG_CONFIG_H__