On Tuesday, 12 July 2016 at 15:09:26 UTC, Adam Sansier wrote:
So, com throughs me a interface ptr and I need to map it to an
interface. When I do, I get an access violation.
I have an (com) ptr and an interface. How do I link them up so
I can call the functions?
I marked the interface extern(C++) so it's a C++ style
interface.
The first field of a COM object is a pointer to its vtable.
This is still true in extern(C++) D, right? The calling
convention is thiscall.
https://dlang.org/spec/cpp_interface.html
I'm not the best person to answer your questions here, but if
you're working with COM you do not want to declare them as
extern(C++). D supported COM long before it did direct C++
interfacing.
You can look at how Juno interfaces with Windows COM objects:
https://github.com/JesseKPhillips/Juno-Windows-Class-Library/blob/master/source/juno/xml/msxml.d#L226
You'll notice that it inherits from IDispatch instead of
IUnknown, Juno defines that interface.
https://github.com/JesseKPhillips/Juno-Windows-Class-Library/blob/master/source/juno/com/core.d#L2063
Juno tries to make it easier to write and interface with COM, but
I've only been keeping it compiling and haven't gotten to writing
my own stuff (I've run into issues with manifest files an such).
It would be awesome if you found it useful and could improve on
the experience.
https://github.com/JesseKPhillips/Juno-Windows-Class-Library/wiki