Hello

I am working on a COM project in which i use Interface Inheritance.

The IDL file looks like this,

interface IEarthInterface : IUnknown
{};
interface IOceanInterface : IEarthInterface
{};
interface IPacificInterface : IOceanInterface
{};
interface IAntarticInterface : IOceanInterface
{};

interface IDataInterface : IUnknown
{};
interface IFindInterface : IDataInterface
{
HRESULT GetOceanTypeInterface(IOceanInterface** pOceanInterface);
};

From inside IFindInterface i need to figure out which Ocean is currently
attached and then attach or typecast
it was IOceanInterface and send it back to client.

All i wanted to know is how to get a Interface pointer from inside another
Interface.

ie, can i call CoCreateInstance or QueryInterface from inside IFindInterface
and get the
Interface Pointer to IPacificInterface or IAntarticInterface.

I been already told that CoCreateInstance will not work in this case.

Any idea how to implement this?

Thanks in advance.

Re: Using QueryInterface inside COM by Maxim

Maxim
Sat Aug 25 14:36:34 CDT 2007

Implement the IOceanInterface::WhatOcean method.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

"Don" <Don@discussions.microsoft.com> wrote in message
news:2D28CCD9-55FB-4B47-BB03-6F0610F4605C@microsoft.com...
> Hello
>
> I am working on a COM project in which i use Interface Inheritance.
>
> The IDL file looks like this,
>
> interface IEarthInterface : IUnknown
> {};
> interface IOceanInterface : IEarthInterface
> {};
> interface IPacificInterface : IOceanInterface
> {};
> interface IAntarticInterface : IOceanInterface
> {};
>
> interface IDataInterface : IUnknown
> {};
> interface IFindInterface : IDataInterface
> {
> HRESULT GetOceanTypeInterface(IOceanInterface** pOceanInterface);
> };
>
> From inside IFindInterface i need to figure out which Ocean is currently
> attached and then attach or typecast
> it was IOceanInterface and send it back to client.
>
> All i wanted to know is how to get a Interface pointer from inside another
> Interface.
>
> ie, can i call CoCreateInstance or QueryInterface from inside IFindInterface
> and get the
> Interface Pointer to IPacificInterface or IAntarticInterface.
>
> I been already told that CoCreateInstance will not work in this case.
>
> Any idea how to implement this?
>
> Thanks in advance.