Racket COM: cannot get IDispatch interface for object - what's next? -
i'm trying use ms ui automation racket 6.x (uiautomationcore.idl under ms sdk uiautomationcore.dll under system) , safe racket call fails cannot idispatch error. code below:
#lang racket (require ffi/com) (define clsid-cuia (string->clsid "{ff48dba4-60ef-4201-aa87-54103eef594e}")) (define cuia-instance (com-create-instance clsid-cuia)) (com-methods cuia-instance) the c++ code works same interface:
cocreateinstance(clsid_cuiautomation, null, clsctx_inproc_server, iid_iuiautomation, reinterpret_cast<void**>(ppautomation)); my question is, should use interface? i've been trying find answer in racket reference have spent lot of time without answers. haven't studied racket c ffi (except section 5.12 com), , wondering whether should learn whole ffi before trying use more advanced code above.
after spending more time on reference (thanks hans' initial comment), know answer. it's not answer how use uia interface, way proceed (as asked in question).
since uiautomation et al derives iunknown, need define com interface using (define-com-interface ...).
a way start is:
(define-com-interface (_iuiautomation _iunknown) ; better approach write macro read idl file, ; , parse it, use result define methods ; , define each corresponding method in order below. first 2 ; doesn't have full description yet ([compareelements _fpointer] [compareruntimeids _fpointer] [getrootelement (_hmfun (p : (_ptr o _iuiautomationelement-pointer)) -> getrootelement p)] )) and since _iuiautomationelement-pointer above not defined yet, should define , other interfaces we'll use separately (define-com-interface ...) well.
there other details take care of converting return values of functions to/from racket values, knowing c ffi help, that's why 1 should better learn racket c ffi before delving further.
here update how use iunknown interface. note _iuiautomation-pointer definition comes automatically define-com-interface above.
(define clsid-cuia (string->clsid "{ff48dba4-60ef-4201-aa87-54103eef594e}")) (define iid_iuiautomation (string->iid "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")) (define cuia (com-create-instance clsid-cuia)) (define iuia (queryinterface (com-object-get-iunknown cuia) iid_iuiautomation _iuiautomation-pointer)) (define root-element (getrootelement iuia))
Comments
Post a Comment