On Thursday, 27 April 2017 at 20:20:23 UTC, Nierjerson wrote:
I think the main issue though, is that I really don't know what
is going on when I invoke the PS function. It seems to call the
server method that takes the interface and then the server does
it's "magic"(which is calling my QueryInterface) but how the
implemented QueryInterface is suppose to respond is beyond
me... I've tried some based stuff but nothing seem to work. The
good news is that it is doing something(calling QueryInterface)
which means that the server is at work.
Any more ideas? I think the issue currently is is the
QueryInterface(it is simply not doing what it is suppose to).
I'll probably have to look at some other implementations to see
what is going on.
QueryInterface is COM's version of opCast. It asks if you support
the interface represented by an IID (riid). If you don't, then
you return E_NOINTERFACE. If you do, then you point the result
(pvObject) to yourself and return S_OK. Here's a basic
implementation:
extern(Windows)
HRESULT QueryInterface(IID* riid, void** pvObject) {
if (pvObject is null) return E_POINTER;
*pvObject = null;
if (*riid == IID_IUnknown) *pvObject =
cast(void*)cast(IUnknown)this;
else if (*riid == IID_IDispatch) *pvObject =
cast(void*)cast(IDispatch)this;
// and so on for all interfaces we support
if (*pvObject is null) return E_NOINTERFACE;
(cast(IUnknown)this).AddRef();
return S_OK;
}
AddRef/Release perform the COM object's reference counting, so
you should implement them too.
However, I don't understand why your icRBCColor class both
implements and encapsulates IDispatch - the generated version
cRGBColor from Gen.d just encapsulates it. Why do you need to
instantiate an instance of icRGBColor? Can't you just use the
rgb1 object you got from the dd.RGB() getter, assign the colour
values to its Red, Blue, Green properties as needed, then call
the dd.RGB(rgb1) setter? Does that not work?