[racket] Com Service with ffi

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Oct 10 08:41:38 EDT 2012

At Wed, 10 Oct 2012 14:33:41 +0200, heraklea at gmx.de wrote:
> Ok,
> 
> I make this:
> 
> (define _ULONG _ulong)
> (define _CATID _GUID)
> (define _REFCATID _GUID-pointer)
> (define-cstruct _CATEGORYINFO ( [catid _CATID]
>                                 [lcid _LCID]
>                                 [szDescription (_array _short 128)]))        
> (define IID_ICustomList
>             (string->iid "{3039E12D-6CEF-4F91-AE9B-E609481C8824}"))
> (define-com-interface (_ICustomList _IUnknown)
>     ([Next/ci (_mfun (_ULONG = 1)
>                  (catinfo : (_ptr o _CATEGORYINFO))
>                 (got : (_ptr o _ULONG))
>                 -> (r : _HRESULT)
>                 -> (cond
>                 [(zero? r) catinfo]
>                 [(= r 1) #f]
>                 [else (windows-error "Next/ci
>     failed" r)]))]
>         [Skip _fpointer]
>         [Reset _fpointer]
>         [Clone _fpointer]))
> 
> 
> But I dont know how to use it, especially in invoking the desired function??


The `show-all-classes' part of the example illustrates how:

 * create an instance of some COM class using `com-create-instance'

 * get an interface-specific reference using `QueryInterface'

 * apply a method as a function with the reference as its first argument,
   like the call to `EnumCategories'.


Posted on the users mailing list.