client.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- // client.cpp
- #define _WIN32_DCOM
- #include <iostream.h>
- #include "Componentcomponent.h"
- void main()
- {
- cout << "Client: Calling CoInitialize()" << endl;
- CoInitializeEx(NULL, COINIT_MULTITHREADED);
-
- ISum* pSum;
- HRESULT hr = CoCreateInstance(CLSID_InsideCOM, NULL, CLSCTX_LOCAL_SERVER, IID_ISum, (void**)&pSum);
- if(FAILED(hr))
- {
- cout << "CoCreateInstance FAILED" << endl;
- return;
- }
- cout << "Client:Calling pSum->Sum" << endl;
- int sum;
- pSum->Sum(4, 5, &sum);
- cout << "Client: Sum 4 + 5 = " << sum << endl;
- pSum->Sum(43, 15, &sum);
- cout << "Client: Sum 43 + 15 = " << sum << endl;
- pSum->Release();
- CoUninitialize();
- }