Prothonotary

prothonotary: A cheif notary or clerk

Overview

This is used to register or unregister COM servers. Use this to implement the /RegServer feature.

Contents

Threading and Housekeeping Issues

This class is not designed with multi-threading access in mind. It is intended to be used in one place in the program, and do so when nothing else is going on.

Usage

Synopsis

Define an instance of type prothonotary, and use members to set information about the component object class (coclass). Then call register or unregister.

void setup_clerk (classics::COM::prothonotary& clerk)
 {
 // identical code for register and unregister
 clerk.set_clsID (__uuidof (my_implementation_class), "My CoClass's Human Name");
 clerk.set_progID (g_szProgID, g_szVerIndProgID);
 clerk.set_threading_model (clerk.Both_thread);
 }


int main (int argc, char* argv[])
 {
 // … blah blah blah
       case UnregServer: {
          classics::COM::prothonotary clerk;
          setup_clerk (clerk);
          return clerk.unregister_server()->as_number();
          }
       case RegServer: {
          classics::COM::prothonotary clerk;
          setup_clerk (clerk);
          int retval= clerk.register_server()->as_number();
          return retval;
          }
 // … blah blah blah
 }

There are other things that have meaningful defaults or automatically figure out the proper values. At minimum, you need to set the clsID.

Details

The COM registration is described in Inside COM by Dale Rogerson, specifically figures 10-6 and 6-4 and the text following the figure.

You can call set_hModule to specify which DLL is the actual COM server. The default is the main EXE, which is correct if you are registering an out-of-process server. This will make it look up the full path and file name of the loaded module. Alternativly, you can call set_server_name directly. For an EXE server, you donít need to do anything.

You can call set_server_type, but if you don’t it will assume you want LocalServer if the server names ends in “.exe” or InprocServer otherwise.

You need to call set_clsID with the GUID and friendly name of the coclass to register. You can also call set_progID.

You can call set_appID too. If you donít, it will set an AppID anyway using the same values as for CLSID. You only need to set the appID once if registering multiple coclasses in one app.

Finally, call register_server or unregister_server. If you have multiple coclasses, set the next CLSID and progID (leave everything else the same) and call it again.