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.

Comments
Just add header
Posted by Legacy on 03/08/2003 12:00amOriginally 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"
ReplyThanks for finding it. :)
Q: modify key with backslash '\'
Posted by Legacy on 10/17/2000 12:00amOriginally 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!
ReplyUli
Comments/Documentation
Posted by Legacy on 09/26/2000 12:00amOriginally posted by: Sanker
ReplyNaming error in file !!
Posted by Legacy on 08/24/2000 12:00amOriginally posted by: S.Anantha Narayanan
ReplyRegistry Access !
Posted by Legacy on 01/20/2000 12:00amOriginally 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