/////////////////////////////////////////////////////////////// // testClient.cpp - client of IRequest interface // // ver 1.0 // // // // demonstrate creation of simple ATL-based, in-process // // component. This client uses _com_ptr and _com_error // // classes. // // // // Language: Visual C++, ver 6.0 // // Platform: Micron Dual Pentium Pro 200, Win NT 4.0 // // Application: Demo: CSE791 - Distributed Objects // // Author: Jim Fawcett, CST 2-187, Syracuse Univ. // // (315) 443-3948, fawcett@ecs.syr.edu // /////////////////////////////////////////////////////////////// #include "..\server\stdafx.h" #include #import "..\server\server.tlb" no_namespace #import "..\client\client.tlb" no_namespace using namespace std; /////////////////////////////////////////////////////////////// // uncomment the EXTERN_C and add server_i.c to project // // if you want to use the ISumPtr pSum(CLSID_Sum) constr'n // // // // EXTERN_C const CLSID CLSID_Sum; // /////////////////////////////////////////////////////////////// void main() { cout << "\n Testing Server Out-of-proc Component " << "\n ======================================\n"; try { CoInitializeEx(NULL,COINIT_APARTMENTTHREADED); /* IRequestPtr pRequest(_T("Server.Request.1")); // IRequestPtr pRequest(CLSID_Sum); BSTR reqStr = SysAllocString(OLESTR("request string from testClient")); pRequest->Request(reqStr); SysFreeString(reqStr); */ IReplyPtr pReply(_T("Client.Reply.1")); BSTR rplStr = SysAllocString(OLESTR("reply string from testClient")); pReply->Reply(rplStr); SysFreeString(rplStr); cout << "\n\n press key to continue\n\n"; char ch; cin.read(&ch,1); } catch(_com_error e) { cout << e.ErrorMessage() << endl; } CoUninitialize(); }