1 // Windows/COM.h 2 3 #ifndef ZIP7_INC_WINDOWS_COM_H 4 #define ZIP7_INC_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 /* 29 class CStgMedium2 30 { 31 STGMEDIUM _object; 32 bool _mustBeReleased; 33 public: 34 CStgMedium2(): _mustBeReleased(false) {} 35 ~CStgMedium2() { Free(); } 36 void Free() 37 { 38 if (_mustBeReleased) 39 ReleaseStgMedium(&_object); 40 _mustBeReleased = false; 41 } 42 const STGMEDIUM* operator->() const { return &_object;} 43 STGMEDIUM* operator->() { return &_object;} 44 STGMEDIUM* operator&() { return &_object; } 45 }; 46 */ 47 48 struct CStgMedium: public STGMEDIUM 49 { CStgMediumCStgMedium50 CStgMedium() 51 { 52 tymed = TYMED_NULL; // 0 53 hGlobal = NULL; 54 pUnkForRelease = NULL; 55 } ~CStgMediumCStgMedium56 ~CStgMedium() 57 { 58 ReleaseStgMedium(this); 59 } 60 }; 61 62 #endif 63 64 /* 65 ////////////////////////////////// 66 // GUID <--> String Conversions 67 UString GUIDToStringW(REFGUID guid); 68 AString GUIDToStringA(REFGUID guid); 69 #ifdef UNICODE 70 #define GUIDToString GUIDToStringW 71 #else 72 #define GUIDToString GUIDToStringA 73 #endif 74 75 HRESULT StringToGUIDW(const wchar_t *string, GUID &classID); 76 HRESULT StringToGUIDA(const char *string, GUID &classID); 77 #ifdef UNICODE 78 #define StringToGUID StringToGUIDW 79 #else 80 #define StringToGUID StringToGUIDA 81 #endif 82 */ 83 84 }} 85 86 #endif 87