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

with-com-interface Macro

Summary

Used to simplify invocation of several methods from a particular COM interface pointer.

Package

com

Signature

with-com-interface disp interface-ptr {form}* => values

disp ::= (dispatch-function interface-name)

Arguments
disp
The names of the dispatch function and interface.
interface-ptr
A form which is evaluated to yield a COM interface pointer that implements interface-name.
form
A form to be evaluated.
dispatch-function
A symbol.
interface-name
A symbol which names the COM interface. It is not evaluated.
Values
values
The values returned by the last form.
Description

The macro with-com-interface evaluates each form in a lexical environment where dispatch-function is defined as a local macro.

dispatch-function can be used to invoked the methods on interface-ptr for the COM interface interface-name, which should be the type or a supertype of the actual type of interface-ptr.

dispatch-function has the following signature:

dispatch-function method-name arg* => values

where:

method-name
A symbol which names the method. It is not evaluated.
arg
Arguments to the method (see 1.8.1 Data conversion when calling COM methods for details).
values
Values from the method (see 1.8.1 Data conversion when calling COM methods for details).
Examples

This example invokes the COM method GetTypeInfo in the interface IDispatch.

(defun get-type-info (disp tinfo &key
                      (locale LOCALE_SYSTEM_DEFAULT))
  (multiple-value-bind (hres typeinfo)
      (with-com-interface (call-disp i-dispatch) disp
        (call-disp get-type-info tinfo locale))
    (check-hresult hres 'get-type-info)
    typeinfo))
See also

call-com-interface


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