Windows Scripting
  Home arrow Windows Scripting arrow Working with the Windows Registry in C++
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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: 4 stars4 stars4 stars4 stars4 stars / 14
    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
     
     
    ADVERTISEMENT


    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...
       · This article has a serious bug!Before calling RegEnumKeyEx, dwSize must be...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek