CRegKey Registry Class

When trying to add registry functionality to a MFC application that I was developing, I looked up CReg* in the Win32 helpfile and sure enough found a CRegKey class. Great! Until you try and use this class in a non ATL (Active Template Library) application, as this code "depends" upon it.

So I went looking at the original source code to see what could possibly be

ATL dependant about the CRegKey registry class, and the answer was- nothing!

So where does the CRegKey class live?

Answer:

Header file:

..\vc\atl\include\atlbase.h

Source file:

..\vc\atl\include\atlimpl.cpp

After removing just the CRegKey code from both the source code and header file, I was able to add the class to my own projects and use it without problem.

The only "advantage" of this code is that it has already been written by Microsoft, so hopefully debugging it would not be an option (I did say hopefully ;-) ). So far it seems to work perfectly without any problems, and lets face it, its not a huge stack of code.

I have posted this discovery because after looking at several newsnet articles, different people had different ideas about how to get the CRegKey class working, but nobody actually suggested just cutting away the code that does the hard work. However, I do fully appreciate that other people may have already written their own classes that may have more functionality.

Download source - 2KB



Comments

  • Just add header

    Posted by Legacy on 03/08/2003 12:00am

    Originally posted by: Mike

    Since you told me where the header file was, I just added it to my view class and it works just find. Why cut and paste? just #include "atlbase.h"
    Thanks for finding it. :)

    Reply
  • Q: modify key with backslash '\'

    Posted by Legacy on 10/17/2000 12:00am

    Originally posted by: Uli Kupferschmitt


    Can anybody give me a hint how to work with
    keys containing a backslash?

    I would like to rename a cdrom drive without user
    interaction (unattended installation). To do this,
    I have to rename the key HKLM|System|MountedDevices|\DosDevices\D:
    The value is binary.

    Thanks!
    Uli

    Reply
  • Comments/Documentation

    Posted by Legacy on 09/26/2000 12:00am

    Originally posted by: Sanker

    Please add comments to the code . If there is any documentation of the class please let me know
    
    Hats up to the excellent work
    Thanks in advance

    Reply
  • Naming error in file !!

    Posted by Legacy on 08/24/2000 12:00am

    Originally posted by: S.Anantha Narayanan

    hi,
    
    

    The file called CRegKey.c has to be renamed as CRegKey.cpp.

    thanks,

    ananth

    Reply
  • Registry Access !

    Posted by Legacy on 01/20/2000 12:00am

    Originally posted by: Phristian P�rstinger

    A very nice example !

    But how can i find out, wich user is logged in on each machine using a self-developed application (VB or VC++)? Can i read it from the registry, but how can i access the registry of any Computer in the Network. Do you please have some source code that can helb me ?

    Greetings !

    Chris

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date