Next Previous Up Top Contents Index

4.6 Building an Automation server application

4.6.11 Local server initialization

Rather than using make to directly instantiate the COM object, a local server should create a class factory. The class <class-factory> is provided as a convenient way to do this. For example:

make(<class-factory>,
     class: <my-dispatch-object>,
     typeinfo: make(<disp-type-info>, ...),
     clsid: make-GUID(...))

This code creates and registers a class factory so that the designated dispinterface class is instantiated when a client tries to invoke a server for the designated Class ID. You can also provide any initialization keywords accepted by the class being instantiated, and the following class factory options:

server-context:

Defaults to $CLSCTX-LOCAL-SERVER.
connection-flags:

Defaults to $REGCLS-SINGLEUSE.

Before your server application terminates, it must call the function revoke-registration, page 227, on the class factory.

As a convenience, making a <class-factory> and calling revoke-registration can be combined by using the macro with-class-factory like this:

with-class-factory (class: <my-dispatch-object>, 
                    typeinfo: make(<disp-type-info>, ...),
                    clsid: make-GUID(...) )

... // body of application

end with-class-factory;

When using a <coclass-type-info>, it contains everything the class factory needs, so the factory can be created simply by doing:

let factory = make-object-factory(my-coclass-type-info);


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

Next Previous Up Top Contents Index