CoGetObject.cpp
上传用户:bjlvip
上传日期:2010-02-08
资源大小:744k
文件大小:1k
源码类别:

Windows编程

开发平台:

Visual C++

  1. #define _WIN32_DCOM
  2. #include <windows.h>
  3. #include <iostream.h>
  4. #include "Componentcomponent.h"
  5. void main()
  6. {
  7. CoInitialize(NULL);
  8. OLECHAR string[] = L"clsid:10000002-0000-0000-0000-000000000001";
  9. IClassFactory* pClassFactory;
  10. CoGetObject(string, 0, IID_IClassFactory, (void**)&pClassFactory);
  11. ISum* pSum;
  12. pClassFactory->CreateInstance(NULL, IID_ISum, (void**)&pSum);
  13. int addition;
  14. pSum->Sum(23, 32, &addition);
  15. cout << "23 + 32 = " << addition << endl;
  16. pSum->Release();
  17. pClassFactory->Release();
  18. CoUninitialize();
  19. }