add COM enumeration support
This commit is contained in:
parent
d22082f7e5
commit
3a75630ea4
|
@ -352,6 +352,29 @@ Racket. (The DLL is the same for all Racket versions.)}
|
||||||
Removes any existing callback for @racket[name] in @racket[obj].}
|
Removes any existing callback for @racket[name] in @racket[obj].}
|
||||||
|
|
||||||
|
|
||||||
|
@; ----------------------------------------
|
||||||
|
|
||||||
|
@section{COM Enumerations}
|
||||||
|
|
||||||
|
@defproc[(com-enumerate-to-list [obj com-object?]) list?]{
|
||||||
|
|
||||||
|
Produces the elements that @racket[obj] would generate as the
|
||||||
|
driver of a for-each loop in Visual Basic or PowerShell.
|
||||||
|
|
||||||
|
A call @racket[(com-enumerate-to-list obj)] is equivalent to
|
||||||
|
@racket[(com-enumeration-to-list (com-get-property obj "_NewEnum"))].
|
||||||
|
|
||||||
|
@history[#:added "6.2.0.2"]}
|
||||||
|
|
||||||
|
|
||||||
|
@defproc[(com-enumeration-to-list [obj com-object?]) list?]{
|
||||||
|
|
||||||
|
Given a COM object that implements @cpp{IEnumVARIANT}, extracts the
|
||||||
|
enumerated values into a list.
|
||||||
|
|
||||||
|
@history[#:added "6.2.0.2"]}
|
||||||
|
|
||||||
|
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
|
|
||||||
@section{Interface Pointers}
|
@section{Interface Pointers}
|
||||||
|
@ -381,7 +404,6 @@ interface} extends @cpp{IUnknown}, so @racket[com-iunknown?] returns
|
||||||
Returns @racket[#t] if @racket[v] corresponds to an unsafe
|
Returns @racket[#t] if @racket[v] corresponds to an unsafe
|
||||||
@cpp{IDispatch}, @racket[#f] otherwise.}
|
@cpp{IDispatch}, @racket[#f] otherwise.}
|
||||||
|
|
||||||
|
|
||||||
@; ----------------------------------------
|
@; ----------------------------------------
|
||||||
|
|
||||||
@section[#:tag "remote"]{Remote COM servers (DCOM)}
|
@section[#:tag "remote"]{Remote COM servers (DCOM)}
|
||||||
|
|
|
@ -24,6 +24,9 @@
|
||||||
com-unregister-event-callback
|
com-unregister-event-callback
|
||||||
com-make-event-executor com-event-executor?
|
com-make-event-executor com-event-executor?
|
||||||
|
|
||||||
|
com-enumeration-to-list
|
||||||
|
com-enumerate-to-list
|
||||||
|
|
||||||
com-object-get-iunknown com-iunknown?
|
com-object-get-iunknown com-iunknown?
|
||||||
com-object-get-idispatch com-idispatch?
|
com-object-get-idispatch com-idispatch?
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,9 @@
|
||||||
com-register-event-callback
|
com-register-event-callback
|
||||||
com-unregister-event-callback
|
com-unregister-event-callback
|
||||||
|
|
||||||
|
com-enumeration-to-list
|
||||||
|
com-enumerate-to-list
|
||||||
|
|
||||||
com-object-get-iunknown com-iunknown?
|
com-object-get-iunknown com-iunknown?
|
||||||
com-object-get-idispatch com-idispatch?
|
com-object-get-idispatch com-idispatch?
|
||||||
|
|
||||||
|
@ -2276,6 +2279,40 @@
|
||||||
(define (com-iunknown? v) (and (IUnknown? v) #t))
|
(define (com-iunknown? v) (and (IUnknown? v) #t))
|
||||||
(define (com-idispatch? v) (and (IDispatch? v) #t))
|
(define (com-idispatch? v) (and (IDispatch? v) #t))
|
||||||
|
|
||||||
|
;; ----------------------------------------
|
||||||
|
;; Enumerations
|
||||||
|
|
||||||
|
(define IID_IEnumVARIANT
|
||||||
|
(string->guid "{00020404-0000-0000-c000-000000000046}"))
|
||||||
|
|
||||||
|
(define-com-interface (_IEnumVARIANT _IUnknown)
|
||||||
|
([Next (_mfun (_ulong = 1)
|
||||||
|
(els : (_ptr o _VARIANT))
|
||||||
|
(got : (_ptr o _ulong))
|
||||||
|
-> (r : _HRESULT)
|
||||||
|
-> (if (= got 1)
|
||||||
|
els
|
||||||
|
#f))]
|
||||||
|
;; ... more methods ...
|
||||||
|
))
|
||||||
|
|
||||||
|
(define (com-enumeration-to-list obj)
|
||||||
|
(define i
|
||||||
|
(QueryInterface (com-object-get-iunknown obj)
|
||||||
|
IID_IEnumVARIANT
|
||||||
|
_IEnumVARIANT-pointer))
|
||||||
|
(begin0
|
||||||
|
(let loop ()
|
||||||
|
(define els (Next i))
|
||||||
|
(if (not els)
|
||||||
|
null
|
||||||
|
(cons (variant-to-scheme els)
|
||||||
|
(loop))))
|
||||||
|
(Release i)))
|
||||||
|
|
||||||
|
(define (com-enumerate-to-list obj)
|
||||||
|
(com-enumeration-to-list (com-get-property obj "_NewEnum")))
|
||||||
|
|
||||||
;; ----------------------------------------
|
;; ----------------------------------------
|
||||||
;; Initialize
|
;; Initialize
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user