Working with Automation datatypes - example
"goobamarino" <[email protected]> Mon, 07 Apr 2003 16:12:15 -0000
| Newsgroups | gmane.lisp.corman |
|---|---|
| Message-ID | <[email protected]> |
Based on a previous message thread with Chris Double, I have put
together an example that works for me. No memory access violations,
no hangs. Note the prototype;
HRESULT LoadTypeLib(
const OLECHAR FAR* szFile,
ITypeLib FAR* FAR* pptlib
);
So I declare (ITYPELIB *) because '&' is used implicitly when the
argument is passed to LoadTypeLib. What is not intuitive to me is
that when I go to use the value (ptlb), I actually deference the
pointer twice, instead of once.
What I plan to do is make some wrapper classes of my own that will
hide some of the less interesting details of how this is actually
done. I have examined Com-type-libs.lisp but those structures still
require a fair amount of FFI knowledge in order to use them.
;;;
;;; Wayne Rogers
;;; short example. Use the path of some known good TypeLib
resource ;;;like c:\\winnt\\\system32\\stdole2.tlb or an ActiveX dll.
(load (concatenate 'string *cormanlisp-directory* "modules\\com-type-
libs.lisp"))
(in-package :win32)
(defmacro create-new (typename)
`(malloc (sizeof ',typename)))
(defun ListTypes (szpath)
(let ((ptlib (create-new (ITypelib *)))
tlib
(name (create-new Bstr))
(doc (create-new Bstr)))
(if (= S_OK (LoadTypeLib (lisp-string-to-unicode szPath)
ptlib))
(progn
(setf tlib (cref ((ITypeLib *) *) ptlib 0))
(format t "~D typedefinitions~%" (ItypeLib-
GetTypeinfoCount tlib))
(dotimes (n (ItypeLib-GetTypeinfoCount
tlib))
(ItypeLib-GetDocumentation tlib n name doc
cl::c_null cl::c_null)
(unless (cpointer-null (cref (BSTR *) name 0))
(format t "~A~%" (unicode-to-lisp-string
(cref (Bstr *) name 0)))))))))
;; one of my COM servers
(ListTypes "c:\\winnt\\\system32\\stdole2.tlb")
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get 128 Bit SSL Encryption!
http://us.click.yahoo.com/xaxhjB/hdqFAA/VygGAA/SyjtlB/TM
---------------------------------------------------------------------~->
To unsubscribe from this group, send an email to:
[email protected]
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/