/////////////////////////////////////////////////////////////// // ATLclient.cpp - client of IString 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, 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 "stdafx.h" #include #include #import "ATLStrings.tlb" no_namespace using namespace std; wstring prefix = L" client:\t\t"; void main() { cout << "\n Testing ATLStrings In-proc Component " << "\n using Visual Studio smart pointer, _com_ptr_t " << "\n ===============================================\n"; try { CoInitializeEx(NULL,COINIT_APARTMENTTHREADED); IStringPtr pString(_T("ATLStrings.String.1")); pString->Fx(L"message from client"); _bstr_t bstr; bstr = pString->Fy(); wchar_t *pBstr = (wchar_t*)bstr; wcout << prefix << pBstr; SysFreeString(pBstr); cout << "\n\n"; } catch(_com_error e) { cout << e.ErrorMessage() << endl; } CoUninitialize(); }