Today i’ve added COM-WRAPPER-CLASS and COM-WRAPPER classes to Doors.

COM-WRAPPER is roughly identical to .NET’s “Runtime callable wrapper” – its instances encapsulate underlying COM objects and all of their interface pointers.

COM-WRAPPER’s SHARED-INITIALIZE method uses CoCreateInstanceEx function to obtain pointer to IUnknown interface and then it uses IUnknown::QueryInterface to obtain other pointers.

Wrappers are garbage-collected, meaning that you should not bother about manually calling AddRef/Release functions.

Here’s an example. Note that it uses HELLO-WORLD-OBJECT class, which is described in the previous post.

(defclass hello-world-wrapper (com-wrapper)
  (:metaclass com-wrapper-class)
  ;;A list of interfaces implemented by this class:
  (:interfaces hello-world)
  ;; In case when :clsid is a string,
  ;; CLSIDFromString function is used to obtain a GUID structure.
  (:clsid . "{DF748DA7-BCB9-4F67-8D32-F9AA1AAA3ABF}"))

;;An example
;;  (which of course implies that you've already registered
;;            a HELLO-WORLD-OBJECT server):
;(defvar *wrapper* (make-instance 'hello-world-wrapper))
;(hello-world *wrapper*) ;; ==> 'Hello, world!' message on *STANDARD-OUTPUT*

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: