client.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- // client.cpp
- #define _WIN32_DCOM
- #include <iostream.h>
- #include "Componentcomponent.h"
- void main()
- {
- HRESULT hr;
- cout << "Client: Calling CoInitialize()" << endl;
- CoInitializeEx(NULL, COINIT_MULTITHREADED);
-
- ISum* pSum = 0;
- 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(73, 15, &sum);
- cout << "Client: Sum 73 + 15 = " << sum << endl;
- pSum->Sum(24, 35, &sum);
- cout << "Client: Sum 24 + 35 = " << sum << endl;
- pSum->Release();
- CoUninitialize();
- }