]>
Commit | Line | Data |
---|---|---|
38b9e339 RN |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: regkey.tex | |
3 | %% Purpose: wxRegKey docs | |
4 | %% Author: Ryan Norton <wxprojects@comcast.net>, C.C.Chakkaradeep | |
5 | %% Modified by: | |
6 | %% Created: 2/5/2005 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) Ryan Norton (C.C.Chakkaradeep?) | |
9 | %% License: wxWindows license | |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
11 | ||
12 | \section{\class{wxRegKey}}\label{wxregkey} | |
13 | ||
6ded0416 VZ |
14 | wxRegKey is a class representing the Windows registry (it is only available |
15 | under Windows). One can create, query and delete registry keys using this | |
16 | class. | |
38b9e339 | 17 | |
6ded0416 VZ |
18 | The Windows registry is easy to understand. There are five registry keys, |
19 | namely: | |
38b9e339 | 20 | |
5e091b2b WS |
21 | \begin{enumerate}\itemsep=0pt |
22 | \item HKEY\_CLASSES\_ROOT (HKCR) | |
23 | \item HKEY\_CURRENT\_USER (HKCU) | |
24 | \item HKEY\_LOCAL\_MACHINE (HKLM) | |
25 | \item HKEY\_CURRENT\_CONFIG (HKCC) | |
26 | \item HKEY\_USERS (HKU) | |
27 | \end{enumerate} | |
38b9e339 | 28 | |
0827d10b | 29 | After creating a key, it can hold a value. The values can be: |
38b9e339 | 30 | |
5e091b2b WS |
31 | \begin{enumerate}\itemsep=0pt |
32 | \item String Value | |
33 | \item Binary Value | |
34 | \item DWORD Value | |
35 | \item Multi String Value | |
36 | \item Expandable String Value | |
37 | \end{enumerate} | |
38 | ||
39 | \wxheading{Derived from} | |
40 | ||
41 | None | |
42 | ||
43 | \wxheading{Include files} | |
44 | ||
6ded0416 | 45 | <wx/msw/registry.h> |
5e091b2b | 46 | |
a7af285d VZ |
47 | \wxheading{Library} |
48 | ||
49 | \helpref{wxBase}{librarieslist} | |
50 | ||
5e091b2b | 51 | \wxheading{Example} |
38b9e339 | 52 | |
38b9e339 RN |
53 | \begin{verbatim} |
54 | wxRegKey *pRegKey = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey"); | |
55 | ||
56 | //will create the Key if it does not exist | |
57 | if( !pRegKey->Exists() ) | |
58 | pRegKey->Create(); | |
59 | ||
60 | //will create a new value MYVALUE and set it to 12 | |
61 | pRegKey->SetValue("MYVALUE",12); | |
62 | ||
63 | //Query for the Value and Retrieve it | |
64 | long lMyVal; | |
65 | wxString strTemp; | |
66 | pRegKey->QueryValue("MYVALUE",&lMyVal); | |
67 | strTemp.Printf("%d",lMyVal); | |
68 | wxMessageBox(strTemp,"Registry Value",0,this); | |
69 | ||
70 | //Retrive the number of SubKeys and enumerate them | |
71 | size_t nSubKeys; | |
72 | pRegKey->GetKeyInfo(&nSubKeys,NULL,NULL,NULL); | |
73 | ||
74 | pRegKey->GetFirstKey(strTemp,1); | |
75 | for(int i=0;i<nSubKeys;i++) | |
76 | { | |
77 | wxMessageBox(strTemp,"SubKey Name",0,this); | |
78 | pRegKey->GetNextKey(strTemp,1); | |
79 | } | |
80 | \end{verbatim} | |
81 | ||
5e091b2b | 82 | \latexignore{\rtfignore{\wxheading{Members}}} |
38b9e339 | 83 | |
6774a5d3 | 84 | |
5e091b2b | 85 | \membersection{wxRegKey::wxRegKey}\label{wxregkeyctor} |
38b9e339 RN |
86 | |
87 | \func{}{wxRegKey}{\void} | |
88 | ||
89 | The Constructor to set to HKCR | |
90 | ||
0827d10b | 91 | \func{}{wxRegKey}{\param{const wxString\&}{ strKey}} |
38b9e339 RN |
92 | |
93 | The constructor to set the full name of the key. | |
94 | ||
0827d10b | 95 | \func{}{wxRegKey}{\param{const wxRegKey\&}{ keyParent}, \param{const wxString\&}{ strKey}} |
38b9e339 | 96 | |
0827d10b | 97 | The constructor to set the full name of the key under a previously created parent. |
38b9e339 | 98 | |
6774a5d3 | 99 | |
38b9e339 RN |
100 | \membersection{wxRegKey::Close}\label{wxregkeyclose} |
101 | ||
102 | \func{void}{Close}{\void} | |
103 | ||
0827d10b | 104 | Closes the key. |
38b9e339 | 105 | |
6774a5d3 | 106 | |
38b9e339 RN |
107 | \membersection{wxRegKey::Create}\label{wxregkeycreate} |
108 | ||
5e091b2b | 109 | \func{bool}{Create}{\param{bool }{bOkIfExists = true}} |
38b9e339 | 110 | |
0827d10b | 111 | Creates the key. Will fail if the key already exists and {\it bOkIfExists} is false. |
38b9e339 | 112 | |
6774a5d3 | 113 | |
38b9e339 RN |
114 | \membersection{wxRegKey::DeleteSelf}\label{wxregkeydeleteself} |
115 | ||
116 | \func{void}{DeleteSelf}{\void} | |
117 | ||
0827d10b | 118 | Deletes this key and all of its subkeys and values recursively. |
38b9e339 | 119 | |
6774a5d3 | 120 | |
38b9e339 RN |
121 | \membersection{wxRegKey::DeleteKey}\label{wxregkeydeletekey} |
122 | ||
123 | \func{void}{DeleteKey}{\param{const wxChar *}{szKey}} | |
124 | ||
0827d10b | 125 | Deletes the subkey with all of its subkeys/values recursively. |
38b9e339 | 126 | |
6774a5d3 | 127 | |
38b9e339 RN |
128 | \membersection{wxRegKey::DeleteValue}\label{wxregkeydeletevalue} |
129 | ||
130 | \func{void}{DeleteValue}{\param{const wxChar *}{szKey}} | |
131 | ||
0827d10b | 132 | Deletes the named value. |
38b9e339 | 133 | |
6774a5d3 | 134 | |
38b9e339 RN |
135 | \membersection{wxRegKey::Exists}\label{wxregkeyexists} |
136 | ||
137 | \constfunc{static bool}{Exists}{\void} | |
138 | ||
0827d10b | 139 | Returns true if the key exists. |
38b9e339 | 140 | |
6774a5d3 | 141 | |
38b9e339 RN |
142 | \membersection{wxRegKey::GetName}\label{wxregkeygetname} |
143 | ||
5e091b2b | 144 | \constfunc{wxString}{GetName}{\param{bool }{bShortPrefix = true}} |
38b9e339 | 145 | |
0827d10b | 146 | Gets the name of the registry key. |
38b9e339 | 147 | |
6774a5d3 | 148 | |
38b9e339 RN |
149 | \membersection{wxRegKey::GetFirstKey}\label{wxregkeygetfirstkey} |
150 | ||
4f0cd9b6 | 151 | \func{bool}{GetFirstKey}{\param{wxString\&}{ strKeyName}, \param{long\&}{ lIndex}} |
38b9e339 | 152 | |
0827d10b | 153 | Gets the first key. |
38b9e339 | 154 | |
6774a5d3 | 155 | |
38b9e339 RN |
156 | \membersection{wxRegKey::GetFirstValue}\label{wxregkeygetfirstvalue} |
157 | ||
0827d10b | 158 | \func{bool}{GetFirstValue}{\param{wxString\&}{ strValueName}, \param{long\&}{ lIndex}} |
38b9e339 | 159 | |
0827d10b | 160 | Gets the first value of this key. |
38b9e339 | 161 | |
6774a5d3 | 162 | |
38b9e339 RN |
163 | \membersection{wxRegKey::GetKeyInfo}\label{wxregkeygetkeyinfo} |
164 | ||
b24442f8 | 165 | \constfunc{bool}{GetKeyInfo}{\param{size\_t *}{pnSubKeys}, \param{size\_t *}{pnValues}, \param{size\_t *}{pnMaxValueLen}} |
38b9e339 | 166 | |
0827d10b | 167 | Gets information about the key. |
38b9e339 | 168 | |
0827d10b | 169 | \wxheading{Parameters} |
38b9e339 | 170 | |
0827d10b | 171 | \docparam{pnSubKeys}{The number of subkeys.} |
38b9e339 | 172 | |
0827d10b JS |
173 | \docparam{pnMaxKeyLen}{The maximum length of the subkey name.} |
174 | ||
175 | \docparam{pnValues}{The number of values.} | |
38b9e339 | 176 | |
b24442f8 VZ |
177 | \docparam{pnMaxValueLen}{The maximum length of a value.} |
178 | ||
6774a5d3 | 179 | |
0827d10b | 180 | \membersection{wxRegKey::GetNextKey}\label{wxregkeygetnextkey} |
38b9e339 | 181 | |
0827d10b | 182 | \constfunc{bool}{GetNextKey}{\param{wxString\&}{ strKeyName}, \param{long\&}{ lIndex}} |
38b9e339 | 183 | |
0827d10b | 184 | Gets the next key. |
38b9e339 | 185 | |
6774a5d3 | 186 | |
38b9e339 RN |
187 | \membersection{wxRegKey::GetNextValue}\label{wxregkeygetnextvalue} |
188 | ||
0827d10b | 189 | \constfunc{bool}{GetNextValue}{\param{wxString\&}{ strValueName}, \param{long\&}{ lIndex}} |
38b9e339 | 190 | |
0827d10b | 191 | Gets the next key value for this key. |
38b9e339 | 192 | |
6774a5d3 | 193 | |
38b9e339 RN |
194 | \membersection{wxRegKey::HasValue}\label{wxregkeyhasvalue} |
195 | ||
196 | \constfunc{bool}{HasValue}{\param{const wxChar *}{szValue}} | |
197 | ||
0827d10b | 198 | Returns true if the value exists. |
38b9e339 | 199 | |
6774a5d3 | 200 | |
38b9e339 RN |
201 | \membersection{wxRegKey::HasValues}\label{wxregkeyhasvalues} |
202 | ||
203 | \constfunc{bool}{HasValues}{\void} | |
204 | ||
0827d10b | 205 | Returns true if any values exist. |
38b9e339 | 206 | |
6774a5d3 | 207 | |
38b9e339 RN |
208 | \membersection{wxRegKey::HasSubKey}\label{wxregkeyhassubkey} |
209 | ||
210 | \constfunc{bool}{HasSubKey}{\param{const wxChar *}{szKey}} | |
211 | ||
0827d10b | 212 | Returns true if given subkey exists. |
38b9e339 | 213 | |
6774a5d3 | 214 | |
38b9e339 RN |
215 | \membersection{wxRegKey::HasSubKeys}\label{wxregkeyhassubkeys} |
216 | ||
217 | \constfunc{bool}{HasSubKeys}{\void} | |
218 | ||
0827d10b | 219 | Returns true if any subkeys exist. |
38b9e339 | 220 | |
6774a5d3 | 221 | |
38b9e339 RN |
222 | \membersection{wxRegKey::IsEmpty}\label{wxregkeyisempty} |
223 | ||
224 | \constfunc{bool}{IsEmpty}{\void} | |
225 | ||
0827d10b | 226 | Returns true if this key is empty, nothing under this key. |
38b9e339 | 227 | |
6774a5d3 | 228 | |
38b9e339 RN |
229 | \membersection{wxRegKey::IsOpened}\label{wxregkeyisopened} |
230 | ||
231 | \constfunc{bool}{IsOpened}{\void} | |
232 | ||
0827d10b | 233 | Returns true if the key is opened. |
38b9e339 | 234 | |
6774a5d3 | 235 | |
38b9e339 RN |
236 | \membersection{wxRegKey::Open}\label{wxregkeyopen} |
237 | ||
6774a5d3 VZ |
238 | \func{bool}{Open}{\param{AccessMode }{mode = Write}} |
239 | ||
240 | Explicitly opens the key. This method also allows the key to be opened in | |
241 | read-only mode by passing \texttt{wxRegKey::Read} instead of default | |
242 | \texttt{wxRegKey::Write} parameter. | |
38b9e339 | 243 | |
38b9e339 RN |
244 | |
245 | \membersection{wxRegKey::QueryValue}\label{wxregkeyqueryvalue} | |
246 | ||
0827d10b | 247 | \constfunc{bool}{QueryValue}{\param{const wxChar *}{szValue}, \param{wxString\&}{ strValue}} |
38b9e339 | 248 | |
0827d10b | 249 | Retrieves the string value. |
38b9e339 RN |
250 | |
251 | \constfunc{bool}{QueryValue}{\param{const wxChar *}{szValue}, \param{long *}{plValue}} | |
252 | ||
0827d10b | 253 | Retrieves the numeric value. |
38b9e339 | 254 | |
6774a5d3 | 255 | |
38b9e339 RN |
256 | \membersection{wxRegKey::Rename}\label{wxregkeyrename} |
257 | ||
258 | \func{bool}{Rename}{\param{const wxChar *}{ szNewName}} | |
259 | ||
0827d10b | 260 | Renames the key. |
38b9e339 | 261 | |
6774a5d3 | 262 | |
38b9e339 RN |
263 | \membersection{wxRegKey::RenameValue}\label{wxregkeyrenamevalue} |
264 | ||
265 | \func{bool}{RenameValue}{\param{const wxChar *}{szValueOld}, \param{const wxChar *}{szValueNew}} | |
266 | ||
0827d10b | 267 | Renames a value. |
38b9e339 | 268 | |
6774a5d3 | 269 | |
38b9e339 RN |
270 | \membersection{wxRegKey::SetValue}\label{wxregkeysetvalue} |
271 | ||
0827d10b JS |
272 | \func{bool}{SetValue}{\param{const wxChar *}{szValue}, \param{long}{ lValue}} |
273 | ||
46512126 VZ |
274 | \func{bool}{SetValue}{\param{const wxChar *}{szValue}, \param{const wxString\&}{ strValue}} |
275 | ||
276 | \func{bool}{SetValue}{\param{const wxChar *}{szValue}, \param{const wxMemoryBuffer\&}{ buf}} | |
277 | ||
278 | Sets the given \arg{szValue} which must be numeric, string or binary depending | |
279 | on the overload used. If the value doesn't exist, it is created. | |
38b9e339 | 280 |