Next Previous Up Top Contents Index

6 The OLE-Server Library

6.5 Implementing local servers

To implement a local server, the basic structure of your application should be the same as any GUI application using the Microsoft Win32 API, with the following exceptions.

Wrap the body of the server application with a call to the function OLE-util-register-only?, page 283, which will test whether the application was passed arguments requiring it to perform a registration operation. Depending on the result of the call, the application can either run as normal, or perform the requested registration operation and exit.
  if (OLE-util-register-only?()) // just [un]register & terminate
   register-ole-server(class-id, prog-id, title-string, 
                       short-name: short-name-string);
  else // actually run the program
  ...
  end if;

When the application is wrapped in this code, if it is run with the /RegServer option (typically done as part of an installation script), it will just register itself and terminate, or if run with the /UnregServer option, it will try to unregister itself and terminate. Otherwise, OLE-util-register-only? returns #f and the application continues to run normally.
COM's class factories are a means of creating multiple instances of a particular COM class. Instantiating the class factory takes care of registering your server application as the process that will serve objects of the given COM class, so that the container can connect to it.
(This registration should not be confused with the registration procedure discussed earlier, which was for registering the application as a server for the COM class or classes it supports, so that the container knows which server application to run.)
Because the OLE-Server instantiates the COM interface object for your server automatically, rather than through calling make on your subclass of <ole-server-framework>, your application will not naturally have a name bound to the COM interface object upon which you can call <class-factory>. You must arrange to bind the instance to a name by defining an initialize method on your subclass of <ole-server-framework>.

OLE, COM, ActiveX and DBMS Reference - 31 MAR 2000

Next Previous Up Top Contents Index