Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
971 B

  1. #ifndef __OLEINIT_HXX__
  2. #define __OLEINIT_HXX__
  3. #include <stdio.h>
  4. class COleInit
  5. {
  6. public:
  7. COleInit(HRESULT *phr);
  8. ~COleInit(void);
  9. private:
  10. // No private data
  11. };
  12. inline COleInit::COleInit(HRESULT *phr)
  13. {
  14. // Initialize the OLE libraries
  15. #ifdef THREADING_SUPPORT
  16. // Look up the thread mode from the win.ini file.
  17. DWORD dwThreadMode;
  18. TCHAR buffer[80];
  19. int len = GetProfileString( TEXT("OleSrv"),
  20. TEXT("ThreadMode"),
  21. TEXT("MultiThreaded"),
  22. buffer, sizeof(buffer) );
  23. if (lstrcmp(buffer, TEXT("SingleThreaded")) == 0)
  24. dwThreadMode = COINIT_SINGLETHREADED;
  25. else
  26. dwThreadMode = COINIT_MULTITHREADED;
  27. // Initialize the OLE libraries
  28. *phr = OleInitializeEx(NULL, dwThreadMode);
  29. #else
  30. *phr = OleInitialize(NULL);
  31. #endif
  32. if (FAILED(*phr))
  33. {
  34. printf ("Failed OleInitialize\n");
  35. }
  36. }
  37. inline COleInit::~COleInit(void)
  38. {
  39. // Do the clean up
  40. OleUninitialize();
  41. }
  42. #endif // __OLEINIT_HXX__