Click here to Skip to main content
15,346,154 members
Articles / Desktop Programming / ATL
Posted 3 Mar 2004


44 bookmarked

Registry Map for RGS files

Rate me:
Please Sign up or sign in to vote.
4.55/5 (16 votes)
3 Mar 20042 min read
Allows custom tags in RGS files to keep GUIDs in sink.


RGS files are a good concept for being able to do some nifty custom registrations in ATL without having to muck round with the registry API.

It appears however, that the writers of ATL never got round to finishing the registry resources. They even passed up on an opportunity to add yet another #define macro map. The full power of the substitutions was just never realized for want of a couple of macros.

A very annoying consequence of this is that whenever you change the CLSID, LIBID, or other attribute of the IDL file, you need to reflect the change in the RGS file. Hands up, how many people have forgotten to do this more than once! (I certainly have).

This utility adds the missing macros, allowing the user to add an RGS substitution map which can include UUIDs as well as strings.


The extra functionality is enabled by using DECLARE_REGISTRY_RESOURCEID_EX(ResourceId) in place of DECLARE_REGISTRY_RESOURCEID(ResourceId). The resource entry used can be of a more generic format, rather than the specific RGS file currently required. This goes, as usual, in the class declaration in the header.

Then, along the same lines as all of the Microsoft macro maps, a map section is required, beginning with BEGIN_REGISTRY_MAP(Class) and ending with END_REGISTRY_MAP(). Inside the registry map is a list containing entries in one of 3 forms:

  • REGMAP_ENTRY(var,subst) Substitute the variable with the given string.
  • REGMAP_RESOURCE(var,resid) Substitute the variable with the string given by the specified resource
  • REGMAP_UUID(var,clsid) Substitute the variable with the string representation of the UUID.

The RGS file for a standard COM library will look like this:

        CLSID = s '%CLSID%'
        CLSID = s '%CLSID%'
        CurVer = s '%PROGID%.%VERSION%'
    NoRemove CLSID
        ForceRemove %CLSID% = s '%DESCRIPTION%'
            ProgID = s '%PROGID%.%VERSION%'
            VersionIndependentProgID = s '%PROGID%'
            ForceRemove 'Programmable'
            InprocServer32 = s '%MODULE%'
                val ThreadingModel = s '%THREADING%'
            'TypeLib' = s '%LIBID%'

The next step is to declare a substitution map. This uses the same format that most of the Microsoft declaration maps follow. If you use the 'RGS' file above, then the map will look something like this:

    REGMAP_ENTRY("PROGID",      "MyLibrary.ClassName")
    REGMAP_ENTRY("VERSION",     "1")
    REGMAP_ENTRY("DESCRIPTION", "ClassName Class")
    REGMAP_UUID ("CLSID",       CLSID_ClassName)
    REGMAP_UUID ("LIBID",       LIBID_MyLibraryLib)
    REGMAP_ENTRY("THREADING",   "Apartment")

This needs to go in the class declaration as well, so I normally place it just below the DECLARE_REGISTRY_RESOURCEID_EX declaration.

Behind the scenes of the extra macros is a simple wrapper for struct _ATL_REGMAP_ENTRY that does some resource management, which is particularly useful for managing the lifetime of the GUID description string.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Michael Geddes
Web Developer
Australia Australia
No Biography provided

Comments and Discussions

QuestionLicense Pin
Member 896106528-May-12 23:21
MemberMember 896106528-May-12 23:21 
QuestionAnyone can modify this source to make it work in VC2010? Pin
ehaerim5-Mar-12 16:58
Memberehaerim5-Mar-12 16:58 
HakunaMatada14-Apr-10 21:25
MemberHakunaMatada14-Apr-10 21:25 
QuestionHow precisely is this used? Pin
Qwertie27-Jan-09 6:16
MemberQwertie27-Jan-09 6:16 
AnswerRe: How precisely is this used? [modified] Pin
Qwertie8-Dec-09 7:07
MemberQwertie8-Dec-09 7:07 
GeneralRe: How precisely is this used? Pin
Michael Geddes23-Feb-11 12:12
MemberMichael Geddes23-Feb-11 12:12 
GeneralRe: How precisely is this used? [modified] Pin
ehaerim18-Feb-12 17:25
Memberehaerim18-Feb-12 17:25 
Have you tried this for VC2010 too?

I am getting some errors and this needs some fix for VC2010.

If you can figure it out please let me know.

GeneralRe: How precisely is this used? [modified] Pin
Qwertie18-Feb-12 20:14
MemberQwertie18-Feb-12 20:14 
GeneralRe: How precisely is this used? [modified] Pin
ehaerim14-Mar-12 7:33
Memberehaerim14-Mar-12 7:33 
GeneralRe: How precisely is this used? [modified] Pin
Qwertie15-Mar-12 10:48
MemberQwertie15-Mar-12 10:48 
QuestionHow is CLSID_ClassName Defined? Pin
Paul Voelker21-Oct-08 7:22
professionalPaul Voelker21-Oct-08 7:22 
AnswerRe: How is CLSID_ClassName Defined? Pin
Jean-Marc Arzoumanian13-Nov-08 12:19
MemberJean-Marc Arzoumanian13-Nov-08 12:19 
QuestionCan you extend this to ATL COM exe server? Pin
ehaerim29-Aug-08 15:38
Memberehaerim29-Aug-08 15:38 
AnswerRe: Can you extend this to ATL COM exe server? Pin
Michael Geddes23-Feb-11 12:15
MemberMichael Geddes23-Feb-11 12:15 
GeneralDemo Pin
Lekrot27-May-07 15:34
MemberLekrot27-May-07 15:34 
GeneralA bit confused.. Pin
rahulN29-Apr-04 4:08
MemberrahulN29-Apr-04 4:08 issue Pin
umgauth014-Apr-04 6:33
Memberumgauth014-Apr-04 6:33 
GeneralRe: .net issue Pin
Michael Geddes14-Apr-04 12:58
MemberMichael Geddes14-Apr-04 12:58 
GeneralWizard for changing UUIDs Pin
snakeware5-Mar-04 1:44
Membersnakeware5-Mar-04 1:44 
GeneralRe: Wizard for changing UUIDs Pin
Michael Geddes5-Mar-04 11:00
MemberMichael Geddes5-Mar-04 11:00 
QuestionWhere? Pin
snakeware5-Mar-04 1:40
Membersnakeware5-Mar-04 1:40 
AnswerRe: Where? Pin
Michael Geddes7-Mar-04 11:08
MemberMichael Geddes7-Mar-04 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.