Click here to Skip to main content
Licence 
First Posted 5 Feb 2002
Views 43,693
Bookmarked 9 times

CRegisterEx - a registry wrapper class

By | 5 Feb 2002 | Article
An easy to use all-in-one registry class

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

S van Leent

Web Developer

Netherlands Netherlands

Member

I'm a developer in C++, however, I developed a lot in VB, Delphi and JAVA. Also I make web based applications using languages as PHP, ASP (JavaScript, VBScript), ASP.NET (C# and VB), JSP and Perl
 
Currently working in a small IT company.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralExcellent example on how it shouldn't be done. Pinsussjfernb10:57 27 May '04  
GeneralRe: Excellent example on how it shouldn't be done. PinmemberS van Leent12:16 27 May '04  
GeneralYou have done well. Pinmembermagic world0:03 11 Jul '03  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 6 Feb 2002
Article Copyright 2002 by S van Leent
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid