Introduction
Always wanted a class that makes it easy to use the register? Well, I hope that
you found it, right here! The class has some methods that you can use
within your program. It's an easy to use class, and I hope you'll like
it.
The class was made using VC++.NET beta 2, but it should be compatible with VC++
5 and 6.
The class is called CRegisterEx
, guess why :)
How is this different to other Registry classes?
Many of the registry wrappers around don't have the functionality to save POINT
and RECT
structures. Thereby,
most of them use RegSetValue
instead of RegSetValueEx
.
The same goes for the Query.
This wrapper is really easy to use, and allows modification. I didn't include things that already were around, but if
people like it, I will do it. So this class is an
attempt to make an easy to use all-in-one Registry wrapper.
Explanation
Construction is done with:
CRegisterEx (CString path);
where path stands for the rootpath. You must construct on the Heap, if you
construct it on the Stack, memory leaks will occur!
The first two methods I'm going to explain are:
void WriteString(CString str, CString subPath, CString Key);
CString ReadString(CString subPath, CString Key);
With WriteString
you can write a string to the register. This you must do by at
least including a CString
. subPath
, which is used to
generate a tree beneath the rootpath, and the Key
attributes don't
have to be included. Remember that the Key attribute will be set to "Standard".
With ReadString
you can read a string from the register.
All other methods are based on these two methods. These are:
void WriteInteger(int i, CString subPath, CString Key);
int ReadInteger(CString subPath, CString Key);
void WritePoint(CPoint pt, CString subPath, CString Key);
CPoint ReadPoint(CString subPath, CString Key);
void WriteRect(CRect rect, CString subPath, CString Key);
CRect ReadRect(CString subPath, CString Key);
void WriteDouble(double dbl, CString subPath, CString Key);
double ReadDouble(CString subPath, CString Key);
As you can see, plenty of methods to use with your program.
If you've got something more to add, please use the forum field below.