1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxRegKey docs
4 %% Author: Ryan Norton <wxprojects@comcast.net>, C.C.Chakkaradeep
8 %% Copyright: (c) Ryan Norton (C.C.Chakkaradeep?)
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxRegKey
}}\label{wxregkey
}
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
18 The Windows registry is easy to understand. There are five registry keys,
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)
29 After creating a key, it can hold a value. The values can be:
31 \begin{enumerate
}\itemsep=
0pt
35 \item Multi String Value
36 \item Expandable String Value
39 \wxheading{Derived from
}
43 \wxheading{Include files
}
49 \helpref{wxBase
}{librarieslist
}
54 wxRegKey *pRegKey = new wxRegKey("HKEY_LOCAL_MACHINE\
\Software\
\MyKey");
56 //will create the Key if it does not exist
57 if( !pRegKey->Exists() )
60 //will create a new value MYVALUE and set it to
12
61 pRegKey->SetValue("MYVALUE",
12);
63 //Query for the Value and Retrieve it
66 pRegKey->QueryValue("MYVALUE",&lMyVal);
67 strTemp.Printf("
%d",lMyVal);
68 wxMessageBox(strTemp,"Registry Value",
0,this);
70 //Retrive the number of SubKeys and enumerate them
72 pRegKey->GetKeyInfo(&nSubKeys,NULL,NULL,NULL);
74 pRegKey->GetFirstKey(strTemp,
1);
75 for(int i=
0;i<nSubKeys;i++)
77 wxMessageBox(strTemp,"SubKey Name",
0,this);
78 pRegKey->GetNextKey(strTemp,
1);
82 \latexignore{\rtfignore{\wxheading{Members
}}}
85 \membersection{wxRegKey::wxRegKey
}\label{wxregkeyctor
}
87 \func{}{wxRegKey
}{\void}
89 The Constructor to set to HKCR
91 \func{}{wxRegKey
}{\param{const wxString\&
}{ strKey
}}
93 The constructor to set the full name of the key.
95 \func{}{wxRegKey
}{\param{const wxRegKey\&
}{ keyParent
},
\param{const wxString\&
}{ strKey
}}
97 The constructor to set the full name of the key under a previously created parent.
100 \membersection{wxRegKey::Close
}\label{wxregkeyclose
}
102 \func{void
}{Close
}{\void}
107 \membersection{wxRegKey::Create
}\label{wxregkeycreate
}
109 \func{bool
}{Create
}{\param{bool
}{bOkIfExists = true
}}
111 Creates the key. Will fail if the key already exists and
{\it bOkIfExists
} is false.
114 \membersection{wxRegKey::DeleteSelf
}\label{wxregkeydeleteself
}
116 \func{void
}{DeleteSelf
}{\void}
118 Deletes this key and all of its subkeys and values recursively.
121 \membersection{wxRegKey::DeleteKey
}\label{wxregkeydeletekey
}
123 \func{void
}{DeleteKey
}{\param{const wxChar *
}{szKey
}}
125 Deletes the subkey with all of its subkeys/values recursively.
128 \membersection{wxRegKey::DeleteValue
}\label{wxregkeydeletevalue
}
130 \func{void
}{DeleteValue
}{\param{const wxChar *
}{szKey
}}
132 Deletes the named value.
135 \membersection{wxRegKey::Exists
}\label{wxregkeyexists
}
137 \constfunc{static bool
}{Exists
}{\void}
139 Returns true if the key exists.
142 \membersection{wxRegKey::GetName
}\label{wxregkeygetname
}
144 \constfunc{wxString
}{GetName
}{\param{bool
}{bShortPrefix = true
}}
146 Gets the name of the registry key.
149 \membersection{wxRegKey::GetFirstKey
}\label{wxregkeygetfirstkey
}
151 \func{bool
}{GetFirstKey
}{\param{wxString\&
}{ strKeyName
},
\param{long\&
}{ lIndex
}}
156 \membersection{wxRegKey::GetFirstValue
}\label{wxregkeygetfirstvalue
}
158 \func{bool
}{GetFirstValue
}{\param{wxString\&
}{ strValueName
},
\param{long\&
}{ lIndex
}}
160 Gets the first value of this key.
163 \membersection{wxRegKey::GetKeyInfo
}\label{wxregkeygetkeyinfo
}
165 \constfunc{bool
}{Exists
}{\param{size
\_t *
}{pnSubKeys
},
\param{size
\_t *
}{pnValues
},
\param{size
\_t *
}{pnMaxValueLen
}}
167 Gets information about the key.
169 \wxheading{Parameters
}
171 \docparam{pnSubKeys
}{The number of subkeys.
}
173 \docparam{pnMaxKeyLen
}{The maximum length of the subkey name.
}
175 \docparam{pnValues
}{The number of values.
}
178 \membersection{wxRegKey::GetNextKey
}\label{wxregkeygetnextkey
}
180 \constfunc{bool
}{GetNextKey
}{\param{wxString\&
}{ strKeyName
},
\param{long\&
}{ lIndex
}}
185 \membersection{wxRegKey::GetNextValue
}\label{wxregkeygetnextvalue
}
187 \constfunc{bool
}{GetNextValue
}{\param{wxString\&
}{ strValueName
},
\param{long\&
}{ lIndex
}}
189 Gets the next key value for this key.
192 \membersection{wxRegKey::HasValue
}\label{wxregkeyhasvalue
}
194 \constfunc{bool
}{HasValue
}{\param{const wxChar *
}{szValue
}}
196 Returns true if the value exists.
199 \membersection{wxRegKey::HasValues
}\label{wxregkeyhasvalues
}
201 \constfunc{bool
}{HasValues
}{\void}
203 Returns true if any values exist.
206 \membersection{wxRegKey::HasSubKey
}\label{wxregkeyhassubkey
}
208 \constfunc{bool
}{HasSubKey
}{\param{const wxChar *
}{szKey
}}
210 Returns true if given subkey exists.
213 \membersection{wxRegKey::HasSubKeys
}\label{wxregkeyhassubkeys
}
215 \constfunc{bool
}{HasSubKeys
}{\void}
217 Returns true if any subkeys exist.
220 \membersection{wxRegKey::IsEmpty
}\label{wxregkeyisempty
}
222 \constfunc{bool
}{IsEmpty
}{\void}
224 Returns true if this key is empty, nothing under this key.
227 \membersection{wxRegKey::IsOpened
}\label{wxregkeyisopened
}
229 \constfunc{bool
}{IsOpened
}{\void}
231 Returns true if the key is opened.
234 \membersection{wxRegKey::Open
}\label{wxregkeyopen
}
236 \func{bool
}{Open
}{\param{AccessMode
}{mode = Write
}}
238 Explicitly opens the key. This method also allows the key to be opened in
239 read-only mode by passing
\texttt{wxRegKey::Read
} instead of default
240 \texttt{wxRegKey::Write
} parameter.
243 \membersection{wxRegKey::QueryValue
}\label{wxregkeyqueryvalue
}
245 \constfunc{bool
}{QueryValue
}{\param{const wxChar *
}{szValue
},
\param{wxString\&
}{ strValue
}}
247 Retrieves the string value.
249 \constfunc{bool
}{QueryValue
}{\param{const wxChar *
}{szValue
},
\param{long *
}{plValue
}}
251 Retrieves the numeric value.
254 \membersection{wxRegKey::Rename
}\label{wxregkeyrename
}
256 \func{bool
}{Rename
}{\param{const wxChar *
}{ szNewName
}}
261 \membersection{wxRegKey::RenameValue
}\label{wxregkeyrenamevalue
}
263 \func{bool
}{RenameValue
}{\param{const wxChar *
}{szValueOld
},
\param{const wxChar *
}{szValueNew
}}
268 \membersection{wxRegKey::SetValue
}\label{wxregkeysetvalue
}
270 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{long
}{ lValue
}}
272 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{const wxString\&
}{ strValue
}}
274 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{const wxMemoryBuffer\&
}{ buf
}}
276 Sets the given
\arg{szValue
} which must be numeric, string or binary depending
277 on the overload used. If the value doesn't exist, it is created.