1 // Windows/COM.h
2 
3 #ifndef __WINDOWS_COM_H
4 #define __WINDOWS_COM_H
5 
6 #include "../Common/MyString.h"
7 
8 namespace NWindows {
9 namespace NCOM {
10 
11 #ifdef _WIN32
12 
13 class CComInitializer
14 {
15 public:
CComInitializer()16   CComInitializer()
17   {
18     #ifdef UNDER_CE
19     CoInitializeEx(NULL, COINIT_MULTITHREADED);
20     #else
21     // it's single thread. Do we need multithread?
22     CoInitialize(NULL);
23     #endif
24   };
~CComInitializer()25   ~CComInitializer() { CoUninitialize(); };
26 };
27 
28 class CStgMedium
29 {
30   STGMEDIUM _object;
31 public:
32   bool _mustBeReleased;
CStgMedium()33   CStgMedium(): _mustBeReleased(false) {}
~CStgMedium()34   ~CStgMedium() { Free(); }
Free()35   void Free()
36   {
37     if (_mustBeReleased)
38       ReleaseStgMedium(&_object);
39     _mustBeReleased = false;
40   }
41   const STGMEDIUM* operator->() const { return &_object;}
42   STGMEDIUM* operator->() { return &_object;}
43   STGMEDIUM* operator&() { return &_object; }
44 };
45 
46 #endif
47 
48 //////////////////////////////////
49 // GUID <--> String Conversions
50 UString GUIDToStringW(REFGUID guid);
51 AString GUIDToStringA(REFGUID guid);
52 #ifdef UNICODE
53   #define GUIDToString GUIDToStringW
54 #else
55   #define GUIDToString GUIDToStringA
56 #endif
57 
58 HRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
59 HRESULT StringToGUIDA(const char *string, GUID &classID);
60 #ifdef UNICODE
61   #define StringToGUID StringToGUIDW
62 #else
63   #define StringToGUID StringToGUIDA
64 #endif
65 
66 }}
67 
68 #endif
69