$szTitle = "wxregkey"; include "./_header.inc"; ?>
wxregkey is a class representing the windows registry (it is only available under windows). one can create, query and delete registry keys using this class.
the windows registry is easy to understand. there are five registry keys, namely:
after creating a key, it can hold a value. the values can be:
derived from
none
include files
<wx/msw/registry.h>
example
wxregkey *pregkey = new wxregkey("hkey_local_machine\\software\\mykey"); //will create the key if it does not exist if( !pregkey->exists() ) pregkey->create(); //will create a new value myvalue and set it to 12 pregkey->setvalue("myvalue",12); //query for the value and retrieve it long lmyval; wxstring strtemp; pregkey->queryvalue("myvalue",&lmyval); strtemp.printf("%d",lmyval); wxmessagebox(strtemp,"registry value",0,this); //retrive the number of subkeys and enumerate them size_t nsubkeys; pregkey->getkeyinfo(&nsubkeys,null,null,null); pregkey->getfirstkey(strtemp,1); for(int i=0;i<nsubkeys;i++) { wxmessagebox(strtemp,"subkey name",0,this); pregkey->getnextkey(strtemp,1); }members
wxregkey::wxregkey
wxregkey::close
wxregkey::create
wxregkey::deleteself
wxregkey::deletekey
wxregkey::deletevalue
wxregkey::exists
wxregkey::getname
wxregkey::getfirstkey
wxregkey::getfirstvalue
wxregkey::getkeyinfo
wxregkey::getnextkey
wxregkey::getnextvalue
wxregkey::hasvalue
wxregkey::hasvalues
wxregkey::hassubkey
wxregkey::hassubkeys
wxregkey::isempty
wxregkey::isopened
wxregkey::open
wxregkey::queryvalue
wxregkey::rename
wxregkey::renamevalue
wxregkey::setvalue
wxregkey()
the constructor to set to hkcr
wxregkey(const wxstring& strkey)
the constructor to set the full name of the key.
wxregkey(const wxregkey& keyparent, const wxstring& strkey)
the constructor to set the full name of the key under a previously created parent.
void close()
closes the key.
bool create(bool bokifexists = true)
creates the key. will fail if the key already exists and bokifexists is false.
void deleteself()
deletes this key and all of its subkeys and values recursively.
void deletekey(const wxchar *szkey)
deletes the subkey with all of its subkeys/values recursively.
void deletevalue(const wxchar *szkey)
deletes the named value.
static bool exists() const
returns true if the key exists.
wxstring getname(bool bshortprefix = true) const
gets the name of the registry key.
bool getfirstkey(wxstring& strkeyname, long& lindex)
gets the first key.
bool getfirstvalue(wxstring& strvaluename, long& lindex)
gets the first value of this key.
bool exists(size_t *pnsubkeys, size_t *pnvalues, size_t *pnmaxvaluelen) const
gets information about the key.
parameters
pnsubkeys
pnmaxkeylen
pnvalues
bool getnextkey(wxstring& strkeyname, long& lindex) const
gets the next key.
bool getnextvalue(wxstring& strvaluename, long& lindex) const
gets the next key value for this key.
bool hasvalue(const wxchar *szvalue) const
returns true if the value exists.
bool hasvalues() const
returns true if any values exist.
bool hassubkey(const wxchar *szkey) const
returns true if given subkey exists.
bool hassubkeys() const
returns true if any subkeys exist.
bool isempty() const
returns true if this key is empty, nothing under this key.
bool isopened() const
returns true if the key is opened.
bool open(accessmode mode = write)
explicitly opens the key. this method also allows the key to be opened in read-only mode by passing wxregkey::read instead of default wxregkey::write parameter.
bool queryvalue(const wxchar *szvalue, wxstring& strvalue) const
retrieves the string value.
bool queryvalue(const wxchar *szvalue, long *plvalue) const
retrieves the numeric value.
bool rename(const wxchar * sznewname)
renames the key.
bool renamevalue(const wxchar *szvalueold, const wxchar *szvaluenew)
renames a value.
bool setvalue(const wxchar *szvalue, long lvalue)
bool setvalue(const wxchar *szvalue, const wxstring& strvalue)
bool setvalue(const wxchar *szvalue, const wxmemorybuffer& buf)
sets the given szvalue which must be numeric, string or binary depending on the overload used. if the value doesn't exist, it is created.
include "./_footer.inc"; ?>