CRegKey Registry Class


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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?


Header file:


Source file:


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


  • Just add header

    Posted by Legacy on 03/08/2003 08: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. :)

  • Q: modify key with backslash '\'

    Posted by Legacy on 10/17/2000 07: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.


  • Comments/Documentation

    Posted by Legacy on 09/26/2000 07: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

  • Naming error in file !!

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

    Originally posted by: S.Anantha Narayanan


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



  • Registry Access !

    Posted by Legacy on 01/20/2000 08: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 !


  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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