summaryrefslogtreecommitdiffstats
path: root/other-licenses/7zstub/src/Windows/COM.cpp
blob: f7ed066ae76725251ec3f94862723a0deb153ef8 (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
// Windows/COM.cpp

#include "StdAfx.h"

#include "Windows/COM.h"
#include "Common/StringConvert.h"

namespace NWindows {
namespace NCOM {

// CoInitialize (NULL); must be called!

UString GUIDToStringW(REFGUID guid)
{
  UString string;
  const int kStringSize = 48;
  StringFromGUID2(guid, string.GetBuffer(kStringSize), kStringSize);
  string.ReleaseBuffer();
  return string;
}

AString GUIDToStringA(REFGUID guid)
{
  return UnicodeStringToMultiByte(GUIDToStringW(guid));
}

HRESULT StringToGUIDW(const wchar_t *string, GUID &classID)
{
  return CLSIDFromString((wchar_t *)string, &classID);
}

HRESULT StringToGUIDA(const char *string, GUID &classID)
{
  return StringToGUIDW(MultiByteToUnicodeString(string), classID);
}

}}