Windows Scripting
  Home arrow Windows Scripting arrow Working with the Windows Registry in C++
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Working with the Windows Registry in C++
By: Barzan "Tony" Antal
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2008-04-02

    Table of Contents:
  • Working with the Windows Registry in C++
  • Basic Registry Functions
  • More Registry Stuff
  • Final Words

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Working with the Windows Registry in C++
    (Page 1 of 4 )

    The Windows Registry is a crucial part of each Microsoft Windows-based operating system. It acts exactly like a directory, storing all kinds of user settings, options, and configuration data about applications, file associations, user policies, and so forth. Therefore, the ability to work with the registry is something that can’t be missing from the arsenal of a software programmer. In this article we are going to learn how to accomplish this task in C++.

    We are going to approach this situation using dedicated API functions that allow us to work with the registry. During this article we’ll learn how to create a console-based application that will be able to do the following: open a specified subkey, create and set a new value, create a new subkey, delete subkeys and values, and dump the content of a particular “tree” (or the whole registry) into a file. We won’t use additional libraries!

    However, at first we’re going to refresh our memory of the structure of the registry so that we crush any possible dilemmas regarding particular terminology such as keys, values, subkeys, name-data pairs, trees, hive, and such. Then we will proceed to creating our application, taking a step-by-step approach while thoroughly explaining the correct usage of the registry functions.

    I wouldn’t classify the required skill level for this tutorial higher than intermediate. Learning how to work with the registry using the soon-to-be-presented functions is almost as easy as learning a Hello World example, if you already know the way the registry works. I foresee that following along will be easy even for a beginner that is familiar with the syntax of C++.

    All of this being said – I invite you to join us for the tutorial.

    The Basics

    It’s important to understand the structure of the registry so that there won’t be any confusion during our explanations later on. Here we’ll be very quick and right on topic because we don’t have time to waste. First of all, you may imagine the registry as a folder. It can have folders and files within it. Now let’s see how we call these.

    The Windows registry contains the following two elements: keys and values. Keys stand for folders of a sort (branches) while the values represent files in our analogy. In reality, values are name-data pairs, meaning that a value is split into two parts: name and data. The name is used for identification purposes and the data part is the actual data.

    Each of the keys can have values but also subkeys. The entire registry is split into logical sections that are called hives. These are the HKCR, HKCU, HKLM, HKU, and HKCC. The whole registry in its entirety is sometimes called the root hive.

    Now my final suggestion before we begin is that you should open your Registry Editor (regedit.exe or regedt32.exe) and look around a bit. Once you can find your way around with ease inside the structure of the your registry, you should be prepared. Oh, and you should backup your registry just in case. However, we won’t do any harm!

    More Windows Scripting Articles
    More By Barzan "Tony" Antal


       · Thanks for reading this article tutorial. I hope you've found it...
     

    WINDOWS SCRIPTING ARTICLES

    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications
    - Securing Computers and Active Directory
    - Moving and Renaming Computers with Active Di...
    - Working with System Processes in WSH
    - Active Directory and Computers
    - WCF and Proxies
    - Metadata and WCF Essentials

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway