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

create-instance Function

Summary

Starts the implementation of a remote COM object and returns its interface pointer.

Package

com

Signature

create-instance clsid &key unknown-outer clsctx riid errorp => interface-ptr

Arguments
clsid
A string or a refguid giving a CLSID to create.
unknown-outer
A COM interface pointer specifying the outer i-unknown if the new instance is to be aggregated.
clsctx
A value from the CLSCTX enumeration.
riid
An optional refiid giving the name of the COM interface return.
errorp
A boolean. The default is t.
Values
interface-ptr
A COM interface pointer for riid.
Description

The function create-instance creates an instance of the COM server associated with clsid and returns an interface pointer for its riid interface. If riid is nil, then i-unknown is used.

If the server cannot be started, then an error of type com-error will be signaled if errorp is true, otherwise nil will be returned.

If unknown-outer is non-nil, it will be passed as the outer unknown interface to be aggregated with the new instance.

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

Notes

You must initialize the COM runtime before calling create-instance (see 1.4 Initializing the COM runtime).

To create an i-dispatch interface and set an event handler, you can use create-instance-with-events.

Examples
(create-instance
 "000209FF-0000-0000-C000-000000000046")
See also

refguid
refiid
i-unknown
create-object
create-instance-with-events


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