[racket-dev] Calling virtual functions
On 2/11/2011 2:04 PM, Kovalev Yuriy wrote:
> I found, that Interface - is just virtual table of methods. So, for
> example, pointer to QueryInterface placed in point of IDispatch's
> address (with no offset) and pointer to method AddRef is placed in
> offset 4 bytes from IDispatch's address... But I still don't know, how
> to use it.
To dig into that vtable, use ptr-ref. Don't forget to pass the
interface back to the method as its first parameter.
Following is untested. Not even paren-balanced.
(let ((addref (ptr-ref pIdisp (_fun #:abi 'stdcall _com-interface ->
_uint) 1))
(release (ptr-ref pIdisp (_fun #:abi 'stdcall _com-interface ->
_uint) 2)))
(addref pIdisp)
...
(release pIdisp))