other-licenses/7zstub/src/Windows/COM.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/Windows/COM.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,37 @@
     1.4 +// Windows/COM.cpp
     1.5 +
     1.6 +#include "StdAfx.h"
     1.7 +
     1.8 +#include "Windows/COM.h"
     1.9 +#include "Common/StringConvert.h"
    1.10 +
    1.11 +namespace NWindows {
    1.12 +namespace NCOM {
    1.13 +
    1.14 +// CoInitialize (NULL); must be called!
    1.15 +
    1.16 +UString GUIDToStringW(REFGUID guid)
    1.17 +{
    1.18 +  UString string;
    1.19 +  const int kStringSize = 48;
    1.20 +  StringFromGUID2(guid, string.GetBuffer(kStringSize), kStringSize);
    1.21 +  string.ReleaseBuffer();
    1.22 +  return string;
    1.23 +}
    1.24 +
    1.25 +AString GUIDToStringA(REFGUID guid)
    1.26 +{
    1.27 +  return UnicodeStringToMultiByte(GUIDToStringW(guid));
    1.28 +}
    1.29 +
    1.30 +HRESULT StringToGUIDW(const wchar_t *string, GUID &classID)
    1.31 +{
    1.32 +  return CLSIDFromString((wchar_t *)string, &classID);
    1.33 +}
    1.34 +
    1.35 +HRESULT StringToGUIDA(const char *string, GUID &classID)
    1.36 +{
    1.37 +  return StringToGUIDW(MultiByteToUnicodeString(string), classID);
    1.38 +}
    1.39 +
    1.40 +}}
    1.41 \ No newline at end of file

mercurial