Commit 1807e534 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

propsys: Add semi-stub for PropVariantToStringAlloc.

parent d17e760c
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
@ stub PropVariantToInt64WithDefault @ stub PropVariantToInt64WithDefault
@ stub PropVariantToStrRet @ stub PropVariantToStrRet
@ stub PropVariantToString @ stub PropVariantToString
@ stub PropVariantToStringAlloc @ stdcall PropVariantToStringAlloc(ptr ptr)
@ stub PropVariantToStringVector @ stub PropVariantToStringVector
@ stub PropVariantToStringVectorAlloc @ stub PropVariantToStringVectorAlloc
@ stub PropVariantToStringWithDefault @ stub PropVariantToStringWithDefault
......
...@@ -209,6 +209,43 @@ HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret) ...@@ -209,6 +209,43 @@ HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret)
return hr; return hr;
} }
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret)
{
WCHAR *res = NULL;
HRESULT hr = S_OK;
TRACE("%p,%p semi-stub\n", propvarIn, ret);
switch(propvarIn->vt)
{
case VT_NULL:
res = CoTaskMemAlloc(1*sizeof(WCHAR));
res[0] = '\0';
break;
case VT_LPSTR:
if(propvarIn->u.pszVal)
{
DWORD len;
len = MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, NULL, 0);
res = CoTaskMemAlloc(len*sizeof(WCHAR));
if(!res)
return E_OUTOFMEMORY;
MultiByteToWideChar(CP_ACP, 0, propvarIn->u.pszVal, -1, res, len);
}
break;
default:
FIXME("Unsupported conversion (%d)\n", propvarIn->vt);
hr = E_FAIL;
break;
}
*ret = res;
return hr;
}
/****************************************************************** /******************************************************************
* PropVariantChangeType (PROPSYS.@) * PropVariantChangeType (PROPSYS.@)
*/ */
......
...@@ -38,6 +38,10 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); ...@@ -38,6 +38,10 @@ DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
DEFINE_GUID(dummy_guid, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe); DEFINE_GUID(dummy_guid, 0xdeadbeef, 0xdead, 0xbeef, 0xde, 0xad, 0xbe, 0xef, 0xca, 0xfe, 0xba, 0xbe);
DEFINE_GUID(expect_guid, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12); DEFINE_GUID(expect_guid, 0x12345678, 0x1234, 0x1234, 0x12, 0x34, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12);
static const char topic[] = "wine topic";
static const WCHAR topicW[] = {'w','i','n','e',' ','t','o','p','i','c',0};
static const WCHAR emptyW[] = {0};
static int strcmp_wa(LPCWSTR strw, const char *stra) static int strcmp_wa(LPCWSTR strw, const char *stra)
{ {
CHAR buf[512]; CHAR buf[512];
...@@ -150,7 +154,6 @@ static void test_PSStringFromPropertyKey(void) ...@@ -150,7 +154,6 @@ static void test_PSStringFromPropertyKey(void)
static void test_PSPropertyKeyFromString(void) static void test_PSPropertyKeyFromString(void)
{ {
static const WCHAR emptyW[] = {0};
static const WCHAR fmtid_clsidW[] = {'S','t','d','F','o','n','t',' ','1',0}; static const WCHAR fmtid_clsidW[] = {'S','t','d','F','o','n','t',' ','1',0};
static const WCHAR fmtid_truncatedW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-', static const WCHAR fmtid_truncatedW[] = {'{','1','2','3','4','5','6','7','8','-','1','2','3','4','-',
'1','2','3','4','-',0}; '1','2','3','4','-',0};
...@@ -616,6 +619,28 @@ static void test_PropVariantToGUID(void) ...@@ -616,6 +619,28 @@ static void test_PropVariantToGUID(void)
PropVariantClear(&propvar); PropVariantClear(&propvar);
} }
static void test_PropVariantToStringAlloc(void)
{
PROPVARIANT prop;
WCHAR *str;
HRESULT hres;
prop.vt = VT_NULL;
hres = PropVariantToStringAlloc(&prop, &str);
ok(hres == S_OK, "returned %x\n", hres);
ok(!lstrcmpW(str, emptyW), "got %s\n", wine_dbgstr_w(str));
CoTaskMemFree(str);
prop.vt = VT_LPSTR;
prop.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
strcpy(prop.u.pszVal, topic);
hres = PropVariantToStringAlloc(&prop, &str);
ok(hres == S_OK, "returned %x\n", hres);
ok(!lstrcmpW(str, topicW), "got %s\n", wine_dbgstr_w(str));
CoTaskMemFree(str);
PropVariantClear(&prop);
}
static void test_PropVariantCompare(void) static void test_PropVariantCompare(void)
{ {
PROPVARIANT empty, null, emptyarray, i2_0, i2_2, i4_large, i4_largeneg, i4_2, str_2, str_02, str_b; PROPVARIANT empty, null, emptyarray, i2_0, i2_2, i4_large, i4_largeneg, i4_2, str_2, str_02, str_b;
...@@ -874,6 +899,7 @@ START_TEST(propsys) ...@@ -874,6 +899,7 @@ START_TEST(propsys)
test_InitPropVariantFromGUIDAsString(); test_InitPropVariantFromGUIDAsString();
test_InitPropVariantFromBuffer(); test_InitPropVariantFromBuffer();
test_PropVariantToGUID(); test_PropVariantToGUID();
test_PropVariantToStringAlloc();
test_PropVariantCompare(); test_PropVariantCompare();
test_intconversions(); test_intconversions();
} }
...@@ -77,6 +77,8 @@ HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret); ...@@ -77,6 +77,8 @@ HRESULT WINAPI PropVariantToUInt16(REFPROPVARIANT propvarIn, USHORT *ret);
HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret); HRESULT WINAPI PropVariantToUInt32(REFPROPVARIANT propvarIn, ULONG *ret);
HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret); HRESULT WINAPI PropVariantToUInt64(REFPROPVARIANT propvarIn, ULONGLONG *ret);
HRESULT WINAPI PropVariantToStringAlloc(REFPROPVARIANT propvarIn, WCHAR **ret);
#ifdef __cplusplus #ifdef __cplusplus
HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar); HRESULT InitPropVariantFromBoolean(BOOL fVal, PROPVARIANT *ppropvar);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment