Self-Registering .EXEs

There isn't an easy way for .EXEs to publish entry points with well-known names, so a direct translation of DllRegisterServer isn't possible. Instead, .EXEs support self-registration using special command line flags. .EXEs that support self-registration must mark their resource fork in the same way as .DLLs, so that the .EXEs support for the command line flags is detectable. Launching an .EXE marked as self-registering with the /REGSERVER command line argument should cause it to do whatever OLE installation is necessary and then exit. The /UNREGSERVER argument is the equivalent to DllUnregisterServer. The /REGSERVER and /UNREGSERVER strings should be treated case-insensitively, and that the character '-' can be substituted for '/'.

Other than guaranteeing that it has the correct entry point or implements the correct command line argument, an application that indicates it is self-registering must build its registration logic so that it may be called any number of times on a given system even if it is already installed. Telling it to register itself more than once should not have any negative side effects. The same is true for unregistering.

On normal startup (without the /REGSERVER command line option) .EXEs should call the registration code to make sure their registry information is current. .EXEs will indicate the failure or success of the self-registration process through their return code by returning zero for success and non-zero for failure.