/////////////////////////////////////////////////////////////// // client.cpp - client of IArray interface // // ver 1.0 // // // // demonstrate creation of simple ATL-based, in-process // // component. This client uses CComQIPtr and IArray // // classes. // // // // Language: Visual C++, ver 6.0, SP 5.0 // // Platform: Dell Dimension 8100, Win2000, SP2 // // Application: Demo: CSE791 - Distributed Objects // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // (315) 443-3948, jfawcett@twcny.rr.com // /////////////////////////////////////////////////////////////// #include #include #include #include #include "A4.h" using namespace std; int main() { cout << "\n Midterm A, Question #4 - out array of shorts " << "\n ===============================================\n" << endl; // Initialize COM Library CoInitialize(NULL) ; wstring prefix = L" Client: \t\t"; try { CComQIPtr pIPtrToDouble; pIPtrToDouble.CoCreateInstance(CLSID_PtrToDouble); DOUBLE dbl = 3.1415927; DOUBLE *pDouble = &dbl; cout << "\n before call to myFunction address of double variable = " << pDouble; if(pIPtrToDouble) { HRESULT hr; hr = pIPtrToDouble->myFunction(pDouble); if(!SUCCEEDED(hr)) throw "call to myFunction(...) failed"; cout << "\n value returned from myFunction = " << dbl; cout << endl; cout << "\n after call to myFunction address of double variable = " << pDouble; } } catch(const char *msg) { cout << "\n " << msg << "\n\n"; } // Uninitialize COM Library // Note: If you declare CComQIPtr in the same scope as CoInitialize // and CoUninitialize(), then you must call pIString.Release() before // calling CoUninitialize(). If declared in a nested scope, as here, // the destructor, ~CComQIPtr() will call release for you, when it // leaves the inner scope. CoUninitialize() ; cout << "\n\n"; return 0 ; }