From 27ac89acbca16531da3af4e021cba54623f85374 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 16 Sep 2011 11:20:07 +0200 Subject: [PATCH] propsys: Added InitVariantFromGUIDAsString implementation. --- dlls/propsys/Makefile.in | 1 + dlls/propsys/propsys.spec | 4 ++-- dlls/propsys/propvar.c | 46 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/dlls/propsys/Makefile.in b/dlls/propsys/Makefile.in index ae2d91fca08..1cbbe7c0a8f 100644 --- a/dlls/propsys/Makefile.in +++ b/dlls/propsys/Makefile.in @@ -1,5 +1,6 @@ MODULE = propsys.dll IMPORTLIB = propsys +IMPORTS = ole32 oleaut32 C_SRCS = \ propsys_main.c \ diff --git a/dlls/propsys/propsys.spec b/dlls/propsys/propsys.spec index 3726facc089..e7389856d73 100644 --- a/dlls/propsys/propsys.spec +++ b/dlls/propsys/propsys.spec @@ -33,7 +33,7 @@ @ stub InitPropVariantFromDoubleVector @ stub InitPropVariantFromFileTime @ stub InitPropVariantFromFileTimeVector -@ stub InitPropVariantFromGUIDAsString +@ stdcall InitPropVariantFromGUIDAsString(ptr ptr) @ stub InitPropVariantFromInt16Vector @ stub InitPropVariantFromInt32Vector @ stub InitPropVariantFromInt64Vector @@ -51,7 +51,7 @@ @ stub InitVariantFromDoubleArray @ stub InitVariantFromFileTime @ stub InitVariantFromFileTimeArray -@ stub InitVariantFromGUIDAsString +@ stdcall InitVariantFromGUIDAsString(ptr ptr) @ stub InitVariantFromInt16Array @ stub InitVariantFromInt32Array @ stub InitVariantFromInt64Array diff --git a/dlls/propsys/propvar.c b/dlls/propsys/propvar.c index cdfb89fa768..d59173c2adb 100644 --- a/dlls/propsys/propvar.c +++ b/dlls/propsys/propvar.c @@ -32,6 +32,7 @@ #include "propvarutil.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(propsys); @@ -86,3 +87,48 @@ HRESULT WINAPI PropVariantChangeType(PROPVARIANT *ppropvarDest, REFPROPVARIANT p return E_FAIL; } + +static void PROPVAR_GUIDToWSTR(REFGUID guid, WCHAR *str) +{ + static const WCHAR format[] = {'{','%','0','8','X','-','%','0','4','X','-','%','0','4','X', + '-','%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2','X', + '%','0','2','X','%','0','2','X','%','0','2','X','}',0}; + + sprintfW(str, format, guid->Data1, guid->Data2, guid->Data3, + guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], + guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]); +} + +HRESULT WINAPI InitPropVariantFromGUIDAsString(REFGUID guid, PROPVARIANT *ppropvar) +{ + TRACE("(%p %p)\n", guid, ppropvar); + + if(!guid) + return E_FAIL; + + ppropvar->vt = VT_LPWSTR; + ppropvar->u.pwszVal = CoTaskMemAlloc(39*sizeof(WCHAR)); + if(!ppropvar->u.pwszVal) + return E_OUTOFMEMORY; + + PROPVAR_GUIDToWSTR(guid, ppropvar->u.pwszVal); + return S_OK; +} + +HRESULT WINAPI InitVariantFromGUIDAsString(REFGUID guid, VARIANT *pvar) +{ + TRACE("(%p %p)\n", guid, pvar); + + if(!guid) { + FIXME("guid == NULL\n"); + return E_FAIL; + } + + V_VT(pvar) = VT_BSTR; + V_BSTR(pvar) = SysAllocStringLen(NULL, 38); + if(!V_BSTR(pvar)) + return E_OUTOFMEMORY; + + PROPVAR_GUIDToWSTR(guid, V_BSTR(pvar)); + return S_OK; +}