Your problem is that IGreet2 is not inherited from IGreet. You must inherit IGreet in IGreet2. In the QueryInterface of IGreet2, you must create an instance of IGreet.
HRESULT __stdcall Greet2::QueryInterface(REFIID riid, void **ppObj)
{
if(riid == IID_IUnknown || riid == IID_IGreet2)
{
*ppObj = static_cast<IGreet2*>(this) ;
reinterpret_cast<IUnknown*> (*ppObj)->AddRef();
return S_OK;
}
else if(riid == IID_Greet)
{
*ppObj = static_cast<IGreet*>(this) ;
reinterpret_cast<IUnknown*> (*ppObj)->AddRef();
return S_OK;
}
else
{
*ppObj = NULL;
return E_NOINTERFACE;
}
}