]>
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 | ||
0827d10b | 14 | wxRegKey is a class representing the Windows registry. One can create, query and delete registry keys using this class. |
38b9e339 | 15 | |
0827d10b | 16 | The Windows registry is easy to understand. There are five registry keys, namely: |
38b9e339 | 17 | |
5e091b2b WS |
18 | \begin{enumerate}\itemsep=0pt |
19 | \item HKEY\_CLASSES\_ROOT (HKCR) | |
20 | \item HKEY\_CURRENT\_USER (HKCU) | |
21 | \item HKEY\_LOCAL\_MACHINE (HKLM) | |
22 | \item HKEY\_CURRENT\_CONFIG (HKCC) | |
23 | \item HKEY\_USERS (HKU) | |
24 | \end{enumerate} | |
38b9e339 | 25 | |
0827d10b | 26 | After creating a key, it can hold a value. The values can be: |
38b9e339 | 27 | |
5e091b2b WS |
28 | \begin{enumerate}\itemsep=0pt |
29 | \item String Value | |
30 | \item Binary Value | |
31 | \item DWORD Value | |
32 | \item Multi String Value | |
33 | \item Expandable String Value | |
34 | \end{enumerate} | |
35 | ||
36 | \wxheading{Derived from} | |
37 | ||
38 | None | |
39 | ||
40 | \wxheading{Include files} | |
41 | ||
42 | <wx/config.h> | |
43 | ||
44 | \wxheading{Example} | |
38b9e339 | 45 | |
38b9e339 RN |
46 | \begin{verbatim} |
47 | wxRegKey *pRegKey = new wxRegKey("HKEY_LOCAL_MACHINE\\Software\\MyKey"); | |
48 | ||
49 | //will create the Key if it does not exist | |
50 | if( !pRegKey->Exists() ) | |
51 | pRegKey->Create(); | |
52 | ||
53 | //will create a new value MYVALUE and set it to 12 | |
54 | pRegKey->SetValue("MYVALUE",12); | |
55 | ||
56 | //Query for the Value and Retrieve it | |
57 | long lMyVal; | |
58 | wxString strTemp; | |
59 | pRegKey->QueryValue("MYVALUE",&lMyVal); | |
60 | strTemp.Printf("%d",lMyVal); | |
61 | wxMessageBox(strTemp,"Registry Value",0,this); | |
62 | ||
63 | //Retrive the number of SubKeys and enumerate them | |
64 | size_t nSubKeys; | |
65 | pRegKey->GetKeyInfo(&nSubKeys,NULL,NULL,NULL); | |
66 | ||
67 | pRegKey->GetFirstKey(strTemp,1); | |
68 | for(int i=0;i<nSubKeys;i++) | |
69 | { | |
70 | wxMessageBox(strTemp,"SubKey Name",0,this); | |
71 | pRegKey->GetNextKey(strTemp,1); | |
72 | } | |
73 | \end{verbatim} | |
74 | ||
5e091b2b | 75 | \latexignore{\rtfignore{\wxheading{Members}}} |
38b9e339 | 76 | |
5e091b2b | 77 | \membersection{wxRegKey::wxRegKey}\label{wxregkeyctor} |
38b9e339 RN |
78 | |
79 | \func{}{wxRegKey}{\void} | |
80 | ||
81 | The Constructor to set to HKCR | |
82 | ||
0827d10b | 83 | \func{}{wxRegKey}{\param{const wxString\&}{ strKey}} |
38b9e339 RN |
84 | |
85 | The constructor to set the full name of the key. | |
86 | ||
0827d10b | 87 | \func{}{wxRegKey}{\param{const wxRegKey\&}{ keyParent}, \param{const wxString\&}{ strKey}} |
38b9e339 | 88 | |
0827d10b | 89 | The constructor to set the full name of the key under a previously created parent. |
38b9e339 RN |
90 | |
91 | \membersection{wxRegKey::Close}\label{wxregkeyclose} | |
92 | ||
93 | \func{void}{Close}{\void} | |
94 | ||
0827d10b | 95 | Closes the key. |
38b9e339 RN |
96 | |
97 | \membersection{wxRegKey::Create}\label{wxregkeycreate} | |
98 | ||
5e091b2b | 99 | \func{bool}{Create}{\param{bool }{bOkIfExists = true}} |
38b9e339 | 100 | |
0827d10b | 101 | Creates the key. Will fail if the key already exists and {\it bOkIfExists} is false. |
38b9e339 RN |
102 | |
103 | \membersection{wxRegKey::DeleteSelf}\label{wxregkeydeleteself} | |
104 | ||
105 | \func{void}{DeleteSelf}{\void} | |
106 | ||
0827d10b | 107 | Deletes this key and all of its subkeys and values recursively. |
38b9e339 RN |
108 | |
109 | \membersection{wxRegKey::DeleteKey}\label{wxregkeydeletekey} | |
110 | ||
111 | \func{void}{DeleteKey}{\param{const wxChar *}{szKey}} | |
112 | ||
0827d10b | 113 | Deletes the subkey with all of its subkeys/values recursively. |
38b9e339 RN |
114 | |
115 | \membersection{wxRegKey::DeleteValue}\label{wxregkeydeletevalue} | |
116 | ||
117 | \func{void}{DeleteValue}{\param{const wxChar *}{szKey}} | |
118 | ||
0827d10b | 119 | Deletes the named value. |
38b9e339 RN |
120 | |
121 | \membersection{wxRegKey::Exists}\label{wxregkeyexists} | |
122 | ||
123 | \constfunc{static bool}{Exists}{\void} | |
124 | ||
0827d10b | 125 | Returns true if the key exists. |
38b9e339 RN |
126 | |
127 | \membersection{wxRegKey::GetName}\label{wxregkeygetname} | |
128 | ||
5e091b2b | 129 | \constfunc{wxString}{GetName}{\param{bool }{bShortPrefix = true}} |
38b9e339 | 130 | |
0827d10b | 131 | Gets the name of the registry key. |
38b9e339 RN |
132 | |
133 | \membersection{wxRegKey::GetFirstKey}\label{wxregkeygetfirstkey} | |
134 | ||
0827d10b | 135 | \func{bool}{GetKeyValue}{\param{wxString\&}{ strKeyName}, \param{long\&}{ lIndex}} |
38b9e339 | 136 | |
0827d10b | 137 | Gets the first key. |
38b9e339 RN |
138 | |
139 | \membersection{wxRegKey::GetFirstValue}\label{wxregkeygetfirstvalue} | |
140 | ||
0827d10b | 141 | \func{bool}{GetFirstValue}{\param{wxString\&}{ strValueName}, \param{long\&}{ lIndex}} |
38b9e339 | 142 | |
0827d10b | 143 | Gets the first value of this key. |
38b9e339 RN |
144 | |
145 | \membersection{wxRegKey::GetKeyInfo}\label{wxregkeygetkeyinfo} | |
146 | ||
147 | \constfunc{bool}{Exists}{\param{size\_t *}{pnSubKeys}, \param{size\_t *}{pnValues}, \param{size\_t *}{pnMaxValueLen}} | |
148 | ||
0827d10b | 149 | Gets information about the key. |
38b9e339 | 150 | |
0827d10b | 151 | \wxheading{Parameters} |
38b9e339 | 152 | |
0827d10b | 153 | \docparam{pnSubKeys}{The number of subkeys.} |
38b9e339 | 154 | |
0827d10b JS |
155 | \docparam{pnMaxKeyLen}{The maximum length of the subkey name.} |
156 | ||
157 | \docparam{pnValues}{The number of values.} | |
38b9e339 | 158 | |
0827d10b | 159 | \membersection{wxRegKey::GetNextKey}\label{wxregkeygetnextkey} |
38b9e339 | 160 | |
0827d10b | 161 | \constfunc{bool}{GetNextKey}{\param{wxString\&}{ strKeyName}, \param{long\&}{ lIndex}} |
38b9e339 | 162 | |
0827d10b | 163 | Gets the next key. |
38b9e339 RN |
164 | |
165 | \membersection{wxRegKey::GetNextValue}\label{wxregkeygetnextvalue} | |
166 | ||
0827d10b | 167 | \constfunc{bool}{GetNextValue}{\param{wxString\&}{ strValueName}, \param{long\&}{ lIndex}} |
38b9e339 | 168 | |
0827d10b | 169 | Gets the next key value for this key. |
38b9e339 RN |
170 | |
171 | \membersection{wxRegKey::HasValue}\label{wxregkeyhasvalue} | |
172 | ||
173 | \constfunc{bool}{HasValue}{\param{const wxChar *}{szValue}} | |
174 | ||
0827d10b | 175 | Returns true if the value exists. |
38b9e339 RN |
176 | |
177 | \membersection{wxRegKey::HasValues}\label{wxregkeyhasvalues} | |
178 | ||
179 | \constfunc{bool}{HasValues}{\void} | |
180 | ||
0827d10b | 181 | Returns true if any values exist. |
38b9e339 RN |
182 | |
183 | \membersection{wxRegKey::HasSubKey}\label{wxregkeyhassubkey} | |
184 | ||
185 | \constfunc{bool}{HasSubKey}{\param{const wxChar *}{szKey}} | |
186 | ||
0827d10b | 187 | Returns true if given subkey exists. |
38b9e339 RN |
188 | |
189 | \membersection{wxRegKey::HasSubKeys}\label{wxregkeyhassubkeys} | |
190 | ||
191 | \constfunc{bool}{HasSubKeys}{\void} | |
192 | ||
0827d10b | 193 | Returns true if any subkeys exist. |
38b9e339 RN |
194 | |
195 | \membersection{wxRegKey::IsEmpty}\label{wxregkeyisempty} | |
196 | ||
197 | \constfunc{bool}{IsEmpty}{\void} | |
198 | ||
0827d10b | 199 | Returns true if this key is empty, nothing under this key. |
38b9e339 RN |
200 | |
201 | \membersection{wxRegKey::IsOpened}\label{wxregkeyisopened} | |
202 | ||
203 | \constfunc{bool}{IsOpened}{\void} | |
204 | ||
0827d10b | 205 | Returns true if the key is opened. |
38b9e339 RN |
206 | |
207 | \membersection{wxRegKey::Open}\label{wxregkeyopen} | |
208 | ||
209 | \func{bool}{Open}{\void} | |
210 | ||
0827d10b | 211 | Explicitly opens the key to be opened. |
38b9e339 RN |
212 | |
213 | \membersection{wxRegKey::QueryValue}\label{wxregkeyqueryvalue} | |
214 | ||
0827d10b | 215 | \constfunc{bool}{QueryValue}{\param{const wxChar *}{szValue}, \param{wxString\&}{ strValue}} |
38b9e339 | 216 | |
0827d10b | 217 | Retrieves the string value. |
38b9e339 RN |
218 | |
219 | \constfunc{bool}{QueryValue}{\param{const wxChar *}{szValue}, \param{long *}{plValue}} | |
220 | ||
0827d10b | 221 | Retrieves the numeric value. |
38b9e339 RN |
222 | |
223 | \membersection{wxRegKey::Rename}\label{wxregkeyrename} | |
224 | ||
225 | \func{bool}{Rename}{\param{const wxChar *}{ szNewName}} | |
226 | ||
0827d10b | 227 | Renames the key. |
38b9e339 RN |
228 | |
229 | \membersection{wxRegKey::RenameValue}\label{wxregkeyrenamevalue} | |
230 | ||
231 | \func{bool}{RenameValue}{\param{const wxChar *}{szValueOld}, \param{const wxChar *}{szValueNew}} | |
232 | ||
0827d10b | 233 | Renames a value. |
38b9e339 RN |
234 | |
235 | \membersection{wxRegKey::SetValue}\label{wxregkeysetvalue} | |
236 | ||
0827d10b JS |
237 | \func{bool}{SetValue}{\param{const wxChar *}{szValue}, \param{long}{ lValue}} |
238 | ||
239 | Sets the numeric value. | |
38b9e339 | 240 |