All Manuals > COM/Automation User Guide and Reference Manual > 4 Automation Reference Entries

with-coclass Macro

Summary

Executes a body of code with a temporary instance of a coclass.

Package

com

Signature

with-coclass disp {form}* => value*

disp ::= (dispatch-function coclass-name &key interface-name punk clsctx)

Arguments
disp
The names of the dispatch function, coclass and so on.
form
A form to be evaluated.
dispatch-function
A symbol which will be defined as a macro, as if by with-dispatch-interface. The macro can be used by forms to invoke the Automation methods of the component.
coclass-name
A symbol which names the coclass. It is not evaluated.
interface-name
A symbol naming an interface in the coclass. It is not evaluated.
punk
A symbol which will be bound to the interface pointer.
clsctx
A CLSCTX value, which defaults to CLSCTX_SERVER.
Values
value*
The values returned by the last form.
Description

The macro with-coclass calls create-object to make an instance of the coclass named by the symbol coclass-name.

If interface-name is supplied then that interface is queried from the component, otherwise the default interface is queried.

Each form is evaluated in turn with dispatch-function bound of a local macro for invoking methods on the interface, as if by with-dispatch-interface. After the forms have been evaluated, the interface pointer is released.

If punk is supplied, it will be bound to the interface pointer while the forms are being evaluated.

clsctx indicate the execution contexts in which an object is to be run. It defaults to CLSCTX_SERVER.

Examples

If a type library containing the coclass TestComponent has been converted to Lisp, then following can be used to make an instance of component and invoke the Greet() method on the default interface.

(with-coclass (call-it test-component)
  (call-it greet "hello"))
See also

create-object


COM/Automation User Guide and Reference Manual - 01 Dec 2021 19:38:41