Click here to Skip to main content
12,998,315 members (58,749 online)
Click here to Skip to main content
Add your own
alternative version

Stats

95.6K views
883 downloads
44 bookmarked
Posted 3 Mar 2004

Registry Map for RGS files

, 3 Mar 2004
Rate this:
Please Sign up or sign in to vote.
Allows custom tags in RGS files to keep GUIDs in sink.

Introduction

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.

Usage

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:

HKCR
{
    %PROGID%.%VERSION% = s '%DESCRIPTION%'
    {
        CLSID = s '%CLSID%'
    }
    %PROGID% = s '%DESCRIPTION%'
    {
        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:

BEGIN_REGISTRY_MAP(CClassName)
    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")
END_REGISTRY_MAP()

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.

License

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

Share

About the Author

Michael Geddes
Web Developer
Australia Australia
No Biography provided

You may also be interested in...

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 
GeneralHKEY_CURRRENT_USER Pin
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 
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
Unknown1421-Oct-08 7:22
memberUnknown1421-Oct-08 7:22 
AnswerRe: How is CLSID_ClassName Defined? Pin
jmarzou13-Nov-08 12:19
memberjmarzou13-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
Flying Spaghetti Monster27-May-07 15:34
memberFlying Spaghetti Monster27-May-07 15:34 
GeneralA bit confused.. Pin
rahulN29-Apr-04 4:08
memberrahulN29-Apr-04 4:08 
General.net 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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170622.1 | Last Updated 4 Mar 2004
Article Copyright 2004 by Michael Geddes
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid