Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi all,

I have 3 instances of a COM server "Slaves" that I need to be accessed from yet another com server "Master" so I registered the Slaves in the ROT. - or so I think. :-)
Here is the code that registers the com server instances in the ROT. The code is
in the constructor.

This works in as much as it does indeed register the GUID(s) in the ROT.
I can open up IROTVEIWER and see my three COM server Slave instances there displayed by !{GUID}.


DWORD ROTCookie = 0;

GUID g;

CoCreateGuid(&g);
RegisterActiveObject(this, g, ACTIVEOBJECT_WEAK, &ROTCookie);

Then I send the GUIDs generated off to the COM server that needs to talk to these
and they arrive as expected and are the values generated back at the constructor.

I grabbed one of the SlaveGUIDs that was sent over from the constructor code above. GetActiveObject seems to work as I can codesense pUnk-> and see the QueryInterface, AddRef and Release funtcions.

But I want one of my own functions (MidiOutFromMaster() to call so I thought I might need to do a QI but it throws up a System.AccessViolationException. I must be doing something wrong along the way . I am a babe in the woods with respect to COM.

I've tried IID_this, that and the other thing out of ignorance in the QI line also.

IUnknown *pUnk;

void** ppv; 


HRESULT hr = GetActiveObject(SlaveGUID, NULL, (IUnknown**)&pUnk);


        hr = pUnk->QueryInterface( IID_IDispatch, ppv ); // causes exemption.


I feel close to my goal however.
Thanks in advance.

:Ron
Posted
Updated 13-Jun-11 16:10pm
v13

1 solution

Fixed it.

hr = pUnk->QueryInterface( IID_IUnknown, (void**)&ppv );
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900