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