Finally, for an Automation controller to be able to invoke an Automation server, the server must be registered in the Windows Registry.
The following code, wrapped around the main program of the server, will take care of registration:
if (OLE-util-register-only?()) // [un]register and terminate register-automation-server(class-id, prog-id, title, ...); register-type-library(coclass-type-info); else ... // everything else here end if;
If this application is executed with the command-line argument /RegServer (case insensitive) it simply records itself in the registry and terminates. Conversely, the command-line argument /UnregServer removes the registry entries.
Note: The server application's full pathname is recorded in the registry, so if you move the application to another directory, you will need to register it again.
After an Automation server creates its class factory, it should enter a normal Windows event loop as any other Windows program would. Requests from the client are automatically dispatched by the default message dispatch mechanism.