1370b324cSopenharmony_ci// Windows/COM.h
2370b324cSopenharmony_ci
3370b324cSopenharmony_ci#ifndef ZIP7_INC_WINDOWS_COM_H
4370b324cSopenharmony_ci#define ZIP7_INC_WINDOWS_COM_H
5370b324cSopenharmony_ci
6370b324cSopenharmony_ci// #include "../Common/MyString.h"
7370b324cSopenharmony_ci
8370b324cSopenharmony_cinamespace NWindows {
9370b324cSopenharmony_cinamespace NCOM {
10370b324cSopenharmony_ci
11370b324cSopenharmony_ci#ifdef _WIN32
12370b324cSopenharmony_ci
13370b324cSopenharmony_ciclass CComInitializer
14370b324cSopenharmony_ci{
15370b324cSopenharmony_cipublic:
16370b324cSopenharmony_ci  CComInitializer()
17370b324cSopenharmony_ci  {
18370b324cSopenharmony_ci    #ifdef UNDER_CE
19370b324cSopenharmony_ci    CoInitializeEx(NULL, COINIT_MULTITHREADED);
20370b324cSopenharmony_ci    #else
21370b324cSopenharmony_ci    // it's single thread. Do we need multithread?
22370b324cSopenharmony_ci    CoInitialize(NULL);
23370b324cSopenharmony_ci    #endif
24370b324cSopenharmony_ci  }
25370b324cSopenharmony_ci  ~CComInitializer() { CoUninitialize(); }
26370b324cSopenharmony_ci};
27370b324cSopenharmony_ci
28370b324cSopenharmony_ci/*
29370b324cSopenharmony_ciclass CStgMedium2
30370b324cSopenharmony_ci{
31370b324cSopenharmony_ci  STGMEDIUM _object;
32370b324cSopenharmony_ci  bool _mustBeReleased;
33370b324cSopenharmony_cipublic:
34370b324cSopenharmony_ci  CStgMedium2(): _mustBeReleased(false) {}
35370b324cSopenharmony_ci  ~CStgMedium2() { Free(); }
36370b324cSopenharmony_ci  void Free()
37370b324cSopenharmony_ci  {
38370b324cSopenharmony_ci    if (_mustBeReleased)
39370b324cSopenharmony_ci      ReleaseStgMedium(&_object);
40370b324cSopenharmony_ci    _mustBeReleased = false;
41370b324cSopenharmony_ci  }
42370b324cSopenharmony_ci  const STGMEDIUM* operator->() const { return &_object;}
43370b324cSopenharmony_ci  STGMEDIUM* operator->() { return &_object;}
44370b324cSopenharmony_ci  STGMEDIUM* operator&() { return &_object; }
45370b324cSopenharmony_ci};
46370b324cSopenharmony_ci*/
47370b324cSopenharmony_ci
48370b324cSopenharmony_cistruct CStgMedium: public STGMEDIUM
49370b324cSopenharmony_ci{
50370b324cSopenharmony_ci  CStgMedium()
51370b324cSopenharmony_ci  {
52370b324cSopenharmony_ci    tymed = TYMED_NULL; // 0
53370b324cSopenharmony_ci    hGlobal = NULL;
54370b324cSopenharmony_ci    pUnkForRelease = NULL;
55370b324cSopenharmony_ci  }
56370b324cSopenharmony_ci  ~CStgMedium()
57370b324cSopenharmony_ci  {
58370b324cSopenharmony_ci    ReleaseStgMedium(this);
59370b324cSopenharmony_ci  }
60370b324cSopenharmony_ci};
61370b324cSopenharmony_ci
62370b324cSopenharmony_ci#endif
63370b324cSopenharmony_ci
64370b324cSopenharmony_ci/*
65370b324cSopenharmony_ci//////////////////////////////////
66370b324cSopenharmony_ci// GUID <--> String Conversions
67370b324cSopenharmony_ciUString GUIDToStringW(REFGUID guid);
68370b324cSopenharmony_ciAString GUIDToStringA(REFGUID guid);
69370b324cSopenharmony_ci#ifdef UNICODE
70370b324cSopenharmony_ci  #define GUIDToString GUIDToStringW
71370b324cSopenharmony_ci#else
72370b324cSopenharmony_ci  #define GUIDToString GUIDToStringA
73370b324cSopenharmony_ci#endif
74370b324cSopenharmony_ci
75370b324cSopenharmony_ciHRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
76370b324cSopenharmony_ciHRESULT StringToGUIDA(const char *string, GUID &classID);
77370b324cSopenharmony_ci#ifdef UNICODE
78370b324cSopenharmony_ci  #define StringToGUID StringToGUIDW
79370b324cSopenharmony_ci#else
80370b324cSopenharmony_ci  #define StringToGUID StringToGUIDA
81370b324cSopenharmony_ci#endif
82370b324cSopenharmony_ci*/
83370b324cSopenharmony_ci
84370b324cSopenharmony_ci}}
85370b324cSopenharmony_ci
86370b324cSopenharmony_ci#endif
87