// SimpleInterfacesClient.cpp : // Illustrates full COM compatibility // // std::out etc #include #include #include "SimpleInterfaces_i.c" #include "SimpleInterfaces.h" int main(int argc, char* argv[]) { HRESULT hr; IX* pX = NULL; IY* pY = NULL; CoInitialize( NULL ); hr = CoCreateInstance( CLSID_CA, NULL, CLSCTX_ALL, IID_IX, (void**) &pX); if ( !SUCCEEDED(hr) ) { std::cout << "ERROR: Unable to create Interface Object!!\n"; switch(hr) { case REGDB_E_CLASSNOTREG: std::cout << " Class not registered.\n"; break; case E_NOINTERFACE : std::cout << " No such interface implemented.\n"; break; case CLASS_E_NOAGGREGATION : std::cout << " No aggregation.\n"; break; default: std::cout << " Unexpected error.\n"; break; } } else { pX->Fx1(); pX->Fx2(); hr = pX->QueryInterface (IID_IY, (void**) &pY); if ( !SUCCEEDED(hr) ) { std::cout << "ERROR: Unable to return pointer to IY!!\n"; } else { pY->Fy1(); pY->Fy2(); pY->Release(); pY = NULL; } pX->Release(); pX = NULL; } CoUninitialize(); return 0; }