Signed-off-by: Jactry Zeng <jzeng(a)codeweavers.com>
---
dlls/propsys/propsys.spec | 2 +-
dlls/propsys/propsys_main.c | 7 +++++
dlls/propsys/tests/propstore.c | 51 ++++++++++++++++++++++++++++++++++
include/propsys.idl | 1 +
4 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/dlls/propsys/propsys.spec b/dlls/propsys/propsys.spec
index bbc71654a8..19c5a24c92 100644
--- a/dlls/propsys/propsys.spec
+++ b/dlls/propsys/propsys.spec
@@ -65,7 +65,7 @@
@ stub PSCoerceToCanonicalValue
@ stub PSCreateAdapterFromPropertyStore
@ stub PSCreateDelayedMultiplexPropertyStore
-@ stub PSCreateMemoryPropertyStore
+@ stdcall PSCreateMemoryPropertyStore(ptr ptr)
@ stub PSCreateMultiplexPropertyStore
@ stub PSCreatePropertyChangeArray
@ stub PSCreatePropertyStoreFromObject
diff --git a/dlls/propsys/propsys_main.c b/dlls/propsys/propsys_main.c
index 1dbaee433f..65d157d0cc 100644
--- a/dlls/propsys/propsys_main.c
+++ b/dlls/propsys/propsys_main.c
@@ -509,3 +509,10 @@ HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR pszString, PROPERTYKEY *pkey)
return S_OK;
}
+
+HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID riid, void **ppv)
+{
+ TRACE("(%s, %p)\n", debugstr_guid(riid), ppv);
+
+ return PropertyStore_CreateInstance(NULL, riid, ppv);
+}
diff --git a/dlls/propsys/tests/propstore.c b/dlls/propsys/tests/propstore.c
index 3fe8613a8b..a24d3e762b 100644
--- a/dlls/propsys/tests/propstore.c
+++ b/dlls/propsys/tests/propstore.c
@@ -35,6 +35,15 @@
DEFINE_GUID(PKEY_WineTest, 0x7b317433, 0xdfa3, 0x4c44, 0xad, 0x3e, 0x2f, 0x80, 0x4b, 0x90, 0xdb, 0xf4);
+#define EXPECT_REF(obj,ref) _expect_ref((IUnknown *)obj, ref, __LINE__)
+static void _expect_ref(IUnknown *obj, ULONG ref, int line)
+{
+ ULONG rc;
+ IUnknown_AddRef(obj);
+ rc = IUnknown_Release(obj);
+ ok_(__FILE__,line)(rc == ref, "expected refcount %d, got %d\n", ref, rc);
+}
+
static void test_inmemorystore(void)
{
IPropertyStoreCache *propcache;
@@ -249,12 +258,54 @@ static void test_persistserialized(void)
IPersistSerializedPropStorage_Release(serialized);
}
+static void test_PSCreateMemoryPropertyStore(void)
+{
+ IPropertyStore *propstore, *propstore1;
+ IPersistSerializedPropStorage *serialized;
+ IPropertyStoreCache *propstorecache;
+ HRESULT hr;
+
+ /* PSCreateMemoryPropertyStore(&IID_IPropertyStore, NULL); crashes */
+
+ hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore);
+ ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr);
+ ok(propstore != NULL, "got %p.\n", propstore);
+ EXPECT_REF(propstore, 1);
+
+ hr = PSCreateMemoryPropertyStore(&IID_IPersistSerializedPropStorage, (void **)&serialized);
+ todo_wine ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr);
+ todo_wine ok(serialized != NULL, "got %p.\n", serialized);
+ EXPECT_REF(propstore, 1);
+ /* EXPECT_REF(serialized, 1); */
+ /* IPersistSerializedPropStorage_Release(serialized); */
+
+ hr = PSCreateMemoryPropertyStore(&IID_IPropertyStoreCache, (void **)&propstorecache);
+ ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr);
+ ok(propstorecache != NULL, "got %p.\n", propstore);
+ ok(propstorecache != (IPropertyStoreCache *)propstore, "pointer are equal: %p, %p.\n", propstorecache, propstore);
+ EXPECT_REF(propstore, 1);
+ EXPECT_REF(propstorecache, 1);
+
+ hr = PSCreateMemoryPropertyStore(&IID_IPropertyStore, (void **)&propstore1);
+ ok(hr == S_OK, "PSCreateMemoryPropertyStore failed: 0x%08x.\n", hr);
+ ok(propstore1 != NULL, "got %p.\n", propstore);
+ ok(propstore1 != propstore, "pointer are equal: %p, %p.\n", propstore1, propstore);
+ EXPECT_REF(propstore, 1);
+ EXPECT_REF(propstore1, 1);
+ EXPECT_REF(propstorecache, 1);
+
+ IPropertyStore_Release(propstore1);
+ IPropertyStore_Release(propstore);
+ IPropertyStoreCache_Release(propstorecache);
+}
+
START_TEST(propstore)
{
CoInitialize(NULL);
test_inmemorystore();
test_persistserialized();
+ test_PSCreateMemoryPropertyStore();
CoUninitialize();
}
diff --git a/include/propsys.idl b/include/propsys.idl
index 04d3fbf8a1..bdd67fa6a5 100644
--- a/include/propsys.idl
+++ b/include/propsys.idl
@@ -799,6 +799,7 @@ cpp_quote("#define PKEY_PIDSTR_MAX 10")
cpp_quote("#define GUIDSTRING_MAX 39")
cpp_quote("#define PKEYSTR_MAX (GUIDSTRING_MAX + 1 + PKEY_PIDSTR_MAX)")
+cpp_quote("HRESULT WINAPI PSCreateMemoryPropertyStore(REFIID,void **);")
cpp_quote("HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY,LPWSTR,UINT);")
cpp_quote("HRESULT WINAPI PSPropertyKeyFromString(LPCWSTR,PROPERTYKEY*);")
cpp_quote("HRESULT WINAPI PSGetPropertyDescription(REFPROPERTYKEY,REFIID,void **);")
--
2.19.2