Q:

Access sub object in COM interface

I want to get access to a sub object of a COM object. In my example I use the CANoe COM Server.
In my program I create a CAN interface to the CANoe Application. Here is an extract of my code so far and it does exactly what I want:
HRESULT result;

//prepare for COM handling...
result = CoInitialize(NULL);

//get CLSID of CANoe...
result = CLSIDFromProgID(L"CANoe.Application", &clsid);

if(SUCCEEDED(result))
{
    //connect to COM interface of CANoe...
    result = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, IID_IApplication, (void**) &pIApp);

    if(SUCCEEDED(result))

    {
        qDebug() << "COM connection established";
    }
    else
    {
        qDebug() << "COM connection error";
    }
}
else
{
    qDebug() << "Error: CLSID";
}

Now I want to get access to a sub object of the COM Server. For example the Measurement object. I tried it with the method pIApp->get_UI() 
IDispatch* pIDis;
IMeasurement* pIMeasurement;

result = pIApp->get_UI(&pIDis);

pIMeasurement = (IMeasurement*) pIDis;

The pointer to the COM object needs to be a pointer of the type IMeasurement, so I can use all the methods defined in the header file. But the method get_UI only supports pointer of the type IDispatch. I tried to cast the pointer from type IDispatch to IMeasurement. But the program crashs at runtime.
I also tried to create a new interface directly to the sub object:
    result = CoCreateInstance(clsid, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, IID_IMeasurement, (void**) &pIMeasurement);

But in this try in the variable result there is saved an error and I can't access the methods of the sub object Measurement.
Where is my mistake and how can I get access to the sub object?
Thank you for all answers and hints!

A:

Thanks to @WhozCraig, @Hans Passant and @Eric Brown for the hints in the comments. 
I was able to solve my problem with the following code:
 IDispatch* pIDispatch;

 //get pointer pIDispatch to Measurement object of CANoe...
 result = pIApp->get_Measurement(&pIDispatch);

 if(SUCCEEDED(result))
 {
    //pointer pIDispatch to pIMeasurement...
    result = pIDispatch->QueryInterface(IID_IMeasurement, (void**) &pIMeasurement);

    if(SUCCEEDED(result))
    {
       pIDispatch->Release();

       //work with connection here...

       pIMeasurement->Release();

    }

 }

