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);
-
- IUnknown* pUnknown;
- ISum* pSum;
- cout << "Client: Calling CoCreateInstance() " << endl;
- CoCreateInstance(CLSID_InsideCOM, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&pUnknown);
- cout << "Client: Calling QueryInterface() for ISum on " << pUnknown << endl;
- HRESULT hr = pUnknown->QueryInterface(IID_ISum, (void**)&pSum);
- if(FAILED(hr))
- cout << "QueryInterface FAILED" << endl;
- cout << "Client: Calling Release() for pUnknown" << endl;
- hr = pUnknown->Release();
- DaysOfTheWeek day = Thursday;
- hr = pSum->Test(day);
- if(SUCCEEDED(hr))
- cout << "Client: Calling Sum() return value is" << endl;
- cout << "Client: Calling Release() for pSum" << endl;
- hr = pSum->Release();
- cout << "Client: Calling CoUninitialize()" << endl;
- CoUninitialize();
- }