client.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
- #define _WIN32_DCOM
- #include <windows.h>
- #include <iostream.h>
- #include <stdio.h>
- #include <conio.h>
- #include "componentcomponent.h"
- void main()
- {
- HRESULT hr;
- hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
- if(FAILED(hr))
- cout << "CoInitializeEx failed. " << endl;
- IPrime* pPrime = 0;
- hr = CoCreateInstance(CLSID_InsideCOM, 0, CLSCTX_LOCAL_SERVER, IID_IPrime, (void**)&pPrime);
- if(FAILED(hr))
- cout << "CoCreateInstance FAILED" << endl;
- IPipeLong* pPipeLong = 0;
- hr = pPrime->QueryInterface(IID_IPipeLong, (void**)&pPipeLong);
- if(FAILED(hr))
- cout << "QueryInterface for IPipeLong FAILED" << endl;
- ULONG pulled = 0;
- long bugger[100000];
- hr = pPipeLong->Pull(bugger, 100000, &pulled);
- if(FAILED(hr))
- cout << "Pull 100 FAILED" << endl;
- cout << "pulled " << pulled << endl;
- _getch();
- for(ULONG count = 0; count < pulled; count++)
- cout << bugger[count] << " ";
-
- pPipeLong->Release();
- for(int testnumber = 1000000; testnumber < 1001000; testnumber++)
- {
- int result = 0;
- hr = pPrime->IsPrime(testnumber, &result);
- if(result)
- cout << endl << testnumber << " is prime." << endl;
- }
- pPrime->Release();
- CoUninitialize();
- }