/////////////////////////////////////////////////////////////// // client.cpp - client for component inproc3 // // // // Platform: Dell Dimension 8100, Windows 2000, SP2 // // Application: Demonstration of ATL 7.0 for CSE775 // // Modified: Jim Fawcett, Syracuse Univ, CST 2-187 // // (315) 443-3948, fawcett@ecs.syr.edu // /////////////////////////////////////////////////////////////// #include #include #include #include "ATLDemo7.h" using namespace std; int main() { cout << "\n Testing in-proc component built with ATL 7.0 " << "\n Sending string and getting back modification " << "\n ================================================\n" << endl; // Initialize COM Library CoInitialize(NULL) ; wstring prefix = L"\n Client: \t"; wcout << prefix + L"Call to CoCreateInstance to create"; wcout << prefix + L" component and get interface IDemo7."; IDemo7* pIDemo7 = NULL ; HRESULT hr = ::CoCreateInstance(CLSID_Demo7, NULL, CLSCTX_INPROC_SERVER, IID_IDemo7, (void**)&pIDemo7) ; if (SUCCEEDED(hr)) { wcout << prefix + L"Succeeded getting IDemo7." << endl; BSTR s = L"Hi There"; BSTR r = L""; hr = pIDemo7->putString(s) ; if(SUCCEEDED(hr)) wcout << prefix << L"sent " << s; else cout << "\n call to putString failed" << endl; hr = pIDemo7->getString(&r) ; if(SUCCEEDED(hr)) wcout << prefix << L"got back " << r; else cout << "\n call to getString failed" << endl; } else { cout << "\n Could not get interface IDemo7." << endl; } wcout << prefix << L"Release IDemo7 interface."; pIDemo7->Release() ; // Uninitialize COM Library CoUninitialize() ; cout << "\n\n"; return 0 ; }