aboutsummaryrefslogtreecommitdiff
path: root/CPP/Windows/COM.h
blob: a8780cacb30cc582cd4c25149bbfa6580b4cb942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Windows/COM.h

#ifndef ZIP7_INC_WINDOWS_COM_H
#define ZIP7_INC_WINDOWS_COM_H

// #include "../Common/MyString.h"

namespace NWindows {
namespace NCOM {

#ifdef _WIN32
  
class CComInitializer
{
public:
  CComInitializer()
  {
    #ifdef UNDER_CE
    CoInitializeEx(NULL, COINIT_MULTITHREADED);
    #else
    // it's single thread. Do we need multithread?
    CoInitialize(NULL);
    #endif
  }
  ~CComInitializer() { CoUninitialize(); }
};

/*
class CStgMedium2
{
  STGMEDIUM _object;
  bool _mustBeReleased;
public:
  CStgMedium2(): _mustBeReleased(false) {}
  ~CStgMedium2() { Free(); }
  void Free()
  {
    if (_mustBeReleased)
      ReleaseStgMedium(&_object);
    _mustBeReleased = false;
  }
  const STGMEDIUM* operator->() const { return &_object;}
  STGMEDIUM* operator->() { return &_object;}
  STGMEDIUM* operator&() { return &_object; }
};
*/

struct CStgMedium: public STGMEDIUM
{
  CStgMedium()
  {
    tymed = TYMED_NULL; // 0
    hGlobal = NULL;
    pUnkForRelease = NULL;
  }
  ~CStgMedium()
  {
    ReleaseStgMedium(this);
  }
};

#endif

/*
//////////////////////////////////
// GUID <--> String Conversions
UString GUIDToStringW(REFGUID guid);
AString GUIDToStringA(REFGUID guid);
#ifdef UNICODE
  #define GUIDToString GUIDToStringW
#else
  #define GUIDToString GUIDToStringA
#endif

HRESULT StringToGUIDW(const wchar_t *string, GUID &classID);
HRESULT StringToGUIDA(const char *string, GUID &classID);
#ifdef UNICODE
  #define StringToGUID StringToGUIDW
#else
  #define StringToGUID StringToGUIDA
#endif
*/

}}

#endif