NextPrevUpTopContentsIndex

with-coclass

Macro
Summary

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

Package

com

Signature

with-coclass disp form * => values

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

Arguments

disp

The names of the dispatch function, coclass etc.

dispatch-function

A symbol which will be defined as a macro, as if by with-dispatch-interface . The macro can be used by the form s 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 .

form

A form to be evaluated.

Values

values

The values returned by the last form .

Description

Calls create-object to make an instance of the coclass named by the symbol coclass-name . If interface-name is given 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 given, it will be bound to the interface pointer while the forms are being evaluated.

Example

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


LispWorks COM/Automation User Guide and Reference Manual - 21 Feb 2008

NextPrevUpTopContentsIndex