All Manuals > COM/Automation User Guide and Reference Manual > 1 Using COM

1.2 Including COM in a Lisp application

This section describes how to load COM and generate any FLI definitions needed to use it, and how to build a COM DLL.

1.2.1 Loading the modules

Before using any of the LispWorks COM API, it must be loaded by evaluating:

(require "com")

1.2.2 Generating FLI definitions from COM definitions

COM definitions are typically described in one of two ways, either as IDL files, which allow the full range of COM definitions or as type libraries, which are generally only used for Automation. Before you can use any COM functionality in a Lisp application, you need to convert the COM definitions into Lisp FLI definitions and various supporting data structures. This corresponds to using midl.exe or the MFC Class Wizard when writing C/C++ COM code.

To convert an IDL file, either compile it using the function midl or add it to a system definition with the option :type :midl-file and compile and load the system.

Note: types like IDispatch must declared before they are used, for this conversion to work.

Conversion of type libraries is covered in 3 Using Automation.

1.2.3 Standard IDL files

Certain standard IDL files have already been converted to FLI definitions as part of the COM API modules. These are listed below and should not be converted again.

Pre converted IDL files
IDL filePart of Lisp module

UNKNWN.IDL

com

WTYPES.IDL

com

OAIDL.IDL

automation

OLEAUTO.IDL

automation

OCIDL.IDL

automation

1.2.4 Making a COM DLL with LispWorks

You can make a DLL with LispWorks by using deliver (or save-image) with the :dll-exports keyword. The value of the :dll-exports keyword can include the keyword :com, which exports (with appropriate definitions) the standard four symbols that a COM DLL needs:

DllGetClassObject
DllRegisterServer
DllUnregisterServer
DllCanUnloadNow

If no other symbols are exported, the value of :dll-exports can be the keyword :com, which means the same as the list (:com). See the Delivery User Guide for more details.

You can use the function set-register-server-error-reporter to report when calls to DllRegisterServer or DllUnregisterServer fail.


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