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
}
50 wxRegKey *pRegKey = new wxRegKey("HKEY_LOCAL_MACHINE\
\Software\
\MyKey");
52 //will create the Key if it does not exist
53 if( !pRegKey->Exists() )
56 //will create a new value MYVALUE and set it to
12
57 pRegKey->SetValue("MYVALUE",
12);
59 //Query for the Value and Retrieve it
62 pRegKey->QueryValue("MYVALUE",&lMyVal);
63 strTemp.Printf("
%d",lMyVal);
64 wxMessageBox(strTemp,"Registry Value",
0,this);
66 //Retrive the number of SubKeys and enumerate them
68 pRegKey->GetKeyInfo(&nSubKeys,NULL,NULL,NULL);
70 pRegKey->GetFirstKey(strTemp,
1);
71 for(int i=
0;i<nSubKeys;i++)
73 wxMessageBox(strTemp,"SubKey Name",
0,this);
74 pRegKey->GetNextKey(strTemp,
1);
78 \latexignore{\rtfignore{\wxheading{Members
}}}
81 \membersection{wxRegKey::wxRegKey
}\label{wxregkeyctor
}
83 \func{}{wxRegKey
}{\void}
85 The Constructor to set to HKCR
87 \func{}{wxRegKey
}{\param{const wxString\&
}{ strKey
}}
89 The constructor to set the full name of the key.
91 \func{}{wxRegKey
}{\param{const wxRegKey\&
}{ keyParent
},
\param{const wxString\&
}{ strKey
}}
93 The constructor to set the full name of the key under a previously created parent.
96 \membersection{wxRegKey::Close
}\label{wxregkeyclose
}
98 \func{void
}{Close
}{\void}
103 \membersection{wxRegKey::Create
}\label{wxregkeycreate
}
105 \func{bool
}{Create
}{\param{bool
}{bOkIfExists = true
}}
107 Creates the key. Will fail if the key already exists and
{\it bOkIfExists
} is false.
110 \membersection{wxRegKey::DeleteSelf
}\label{wxregkeydeleteself
}
112 \func{void
}{DeleteSelf
}{\void}
114 Deletes this key and all of its subkeys and values recursively.
117 \membersection{wxRegKey::DeleteKey
}\label{wxregkeydeletekey
}
119 \func{void
}{DeleteKey
}{\param{const wxChar *
}{szKey
}}
121 Deletes the subkey with all of its subkeys/values recursively.
124 \membersection{wxRegKey::DeleteValue
}\label{wxregkeydeletevalue
}
126 \func{void
}{DeleteValue
}{\param{const wxChar *
}{szKey
}}
128 Deletes the named value.
131 \membersection{wxRegKey::Exists
}\label{wxregkeyexists
}
133 \constfunc{static bool
}{Exists
}{\void}
135 Returns true if the key exists.
138 \membersection{wxRegKey::GetName
}\label{wxregkeygetname
}
140 \constfunc{wxString
}{GetName
}{\param{bool
}{bShortPrefix = true
}}
142 Gets the name of the registry key.
145 \membersection{wxRegKey::GetFirstKey
}\label{wxregkeygetfirstkey
}
147 \func{bool
}{GetKeyValue
}{\param{wxString\&
}{ strKeyName
},
\param{long\&
}{ lIndex
}}
152 \membersection{wxRegKey::GetFirstValue
}\label{wxregkeygetfirstvalue
}
154 \func{bool
}{GetFirstValue
}{\param{wxString\&
}{ strValueName
},
\param{long\&
}{ lIndex
}}
156 Gets the first value of this key.
159 \membersection{wxRegKey::GetKeyInfo
}\label{wxregkeygetkeyinfo
}
161 \constfunc{bool
}{Exists
}{\param{size
\_t *
}{pnSubKeys
},
\param{size
\_t *
}{pnValues
},
\param{size
\_t *
}{pnMaxValueLen
}}
163 Gets information about the key.
165 \wxheading{Parameters
}
167 \docparam{pnSubKeys
}{The number of subkeys.
}
169 \docparam{pnMaxKeyLen
}{The maximum length of the subkey name.
}
171 \docparam{pnValues
}{The number of values.
}
174 \membersection{wxRegKey::GetNextKey
}\label{wxregkeygetnextkey
}
176 \constfunc{bool
}{GetNextKey
}{\param{wxString\&
}{ strKeyName
},
\param{long\&
}{ lIndex
}}
181 \membersection{wxRegKey::GetNextValue
}\label{wxregkeygetnextvalue
}
183 \constfunc{bool
}{GetNextValue
}{\param{wxString\&
}{ strValueName
},
\param{long\&
}{ lIndex
}}
185 Gets the next key value for this key.
188 \membersection{wxRegKey::HasValue
}\label{wxregkeyhasvalue
}
190 \constfunc{bool
}{HasValue
}{\param{const wxChar *
}{szValue
}}
192 Returns true if the value exists.
195 \membersection{wxRegKey::HasValues
}\label{wxregkeyhasvalues
}
197 \constfunc{bool
}{HasValues
}{\void}
199 Returns true if any values exist.
202 \membersection{wxRegKey::HasSubKey
}\label{wxregkeyhassubkey
}
204 \constfunc{bool
}{HasSubKey
}{\param{const wxChar *
}{szKey
}}
206 Returns true if given subkey exists.
209 \membersection{wxRegKey::HasSubKeys
}\label{wxregkeyhassubkeys
}
211 \constfunc{bool
}{HasSubKeys
}{\void}
213 Returns true if any subkeys exist.
216 \membersection{wxRegKey::IsEmpty
}\label{wxregkeyisempty
}
218 \constfunc{bool
}{IsEmpty
}{\void}
220 Returns true if this key is empty, nothing under this key.
223 \membersection{wxRegKey::IsOpened
}\label{wxregkeyisopened
}
225 \constfunc{bool
}{IsOpened
}{\void}
227 Returns true if the key is opened.
230 \membersection{wxRegKey::Open
}\label{wxregkeyopen
}
232 \func{bool
}{Open
}{\param{AccessMode
}{mode = Write
}}
234 Explicitly opens the key. This method also allows the key to be opened in
235 read-only mode by passing
\texttt{wxRegKey::Read
} instead of default
236 \texttt{wxRegKey::Write
} parameter.
239 \membersection{wxRegKey::QueryValue
}\label{wxregkeyqueryvalue
}
241 \constfunc{bool
}{QueryValue
}{\param{const wxChar *
}{szValue
},
\param{wxString\&
}{ strValue
}}
243 Retrieves the string value.
245 \constfunc{bool
}{QueryValue
}{\param{const wxChar *
}{szValue
},
\param{long *
}{plValue
}}
247 Retrieves the numeric value.
250 \membersection{wxRegKey::Rename
}\label{wxregkeyrename
}
252 \func{bool
}{Rename
}{\param{const wxChar *
}{ szNewName
}}
257 \membersection{wxRegKey::RenameValue
}\label{wxregkeyrenamevalue
}
259 \func{bool
}{RenameValue
}{\param{const wxChar *
}{szValueOld
},
\param{const wxChar *
}{szValueNew
}}
264 \membersection{wxRegKey::SetValue
}\label{wxregkeysetvalue
}
266 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{long
}{ lValue
}}
268 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{const wxString\&
}{ strValue
}}
270 \func{bool
}{SetValue
}{\param{const wxChar *
}{szValue
},
\param{const wxMemoryBuffer\&
}{ buf
}}
272 Sets the given
\arg{szValue
} which must be numeric, string or binary depending
273 on the overload used. If the value doesn't exist, it is created.