Click here to Skip to main content
15,881,139 members
Articles / Programming Languages / C++
Article

Class to handle the Windows Registry operations

Rate me:
Please Sign up or sign in to vote.
1.00/5 (14 votes)
27 Nov 20072 min read 25.7K   444   15   2
A class to handle the Windows registry more smoothly.

Introduction

As most of the beginners are not well aware about the windows registery, they usually come with problems just by deleting the main nodes of windows, which leads to Windows to get hanged or even crash. And then, they got the crazy to start programming with the Windows registry. Windows Registry programming is extremely easy. There are two provisions provided by windows for doing this. One is using of SDK or MFC. But both cases we dont have a API that can create a node and set the value using a single API, which is one of the most important constraint in front of us. So to solve this, I came up with a solution to write a class that can do both creation as setting the value using a single API.

Background

Beginners to windows programming are eager to get started with the Windows registry programming. While doing the programming and handling with registry, please be careful not to delete any important nodes that are essential for the working of windows. And for a beginner, I will say you to stick with SDK rather than MFC. I know both of these will not there in Windows Vista. But still SDK is the base for the Windows programmer.

Using the code

A brief description of how to use the article or code. The class names, the methods and properties, any tricks or tips.

Blocks of code should be set as style "Formatted" like this:

    CRegistry reg;
    HKEY hkey = KEY_ALL_ACCESS;
    DWORD dwData = 0;
//  This code will create a registry entry corresponding to this code.
    reg.CreateRegistryKey(HKEY_CURRENT_USER,_T( "Software\\MySoftware" ),hkey,dwData);
    reg. CreateAndSetValue( HKEY_CURRENT_USER, ,_T( "Software\\MySoftware" ),
              _T( "MyValue" ), _T( "Value1" ))

Points of Interest

Hope you all know what is a windows registry, We can call it as a configuration handling section. It is responsibility of the registry to keep all the configurations needed for the Windows to get worked proparly. Earlier days, INI files were used for the configuration handling, but it was never being a proper solution to keep the configurations in INI, since it got scattered here and there . So they are kept in a directory it can be called as Windows Registry. The registry also provides a window into the operation of the kernel, exposing runtime information such as performance counters and currently active hardware. This use of registry mechanism is conceptually similar to the way that Sysfs and procfs expose runtime information through the file system.

History

Please provide the feedback about the topic.

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


Written By
Software Developer
India India
If there is no way, make a way.
Believe me, you can do that.

In the software history, you can never find a software without bug, It is made the best after continuos attempts.

Comments and Discussions

 
QuestionIs this any different? Pin
John M. Drescher27-Nov-07 6:19
John M. Drescher27-Nov-07 6:19 
AnswerRe: Is this any different? Pin
rajajay8227-Nov-07 16:59
rajajay8227-Nov-07 16:59 

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

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