On Tuesday, 12 July 2016 at 23:55:55 UTC, Adam Sansier wrote:


Ok, Another hack:

                iInterface x;
                void** y = cast(void**)&x;
                *y = malloc(iInterface.sizeof);
                
                x.__vptr = cast(immutable(void*)*)(*ptr);
                x.func();

works.

x is the object of type iInterface. It has no object associated with it, basically create one using malloc and set it's vtable.

this avoids the need to create the class.

What happens when you declare an interface that extends from IUnknown (and not extern(C++)), then cast the pointer returned from the COM API? It should just work without needing to muck around with the vtable.

Reply via email to