other-licenses/7zstub/src/Windows/COM.cpp
author joshmoz@gmail.com
Tue, 26 Feb 2008 18:03:08 -0800
changeset 12311 ffbd523d0ada4d3a6ea396cb1e440b82bbd94b68
parent 1 9b2a99adc05e53cd4010de512f50118594756650
permissions -rw-r--r--
rename files to .mm. b=419390,419392 r/sr=roc

// 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);
}

}}