[PATCH] devenum: Do not fail with a IBindCtx (with tests)

Detlef Riekenberg wine.dev at web.de
Tue May 15 17:21:52 CDT 2012


(The test dump only the first entry to reduce the logfile size)

Needed to get this test app working:

http://blogs.msdn.com/b/matthew_van_eerde/archive/2010/05/25/how-to-enumerate-directshow-filters-on-your-system.aspx

--
By by ... Detlef
---
 dlls/devenum/mediacatenum.c  |    9 +++++++-
 dlls/devenum/tests/devenum.c |   48 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 1 deletions(-)

diff --git a/dlls/devenum/mediacatenum.c b/dlls/devenum/mediacatenum.c
index 1ff06df..6922969 100644
--- a/dlls/devenum/mediacatenum.c
+++ b/dlls/devenum/mediacatenum.c
@@ -459,13 +459,20 @@ static HRESULT WINAPI DEVENUM_IMediaCatMoniker_BindToObject(IMoniker *iface, IBi
 static HRESULT WINAPI DEVENUM_IMediaCatMoniker_BindToStorage(IMoniker *iface, IBindCtx *pbc,
         IMoniker *pmkToLeft, REFIID riid, void **ppvObj)
 {
+    static IBindCtx *old_bc;
     MediaCatMoniker *This = impl_from_IMoniker(iface);
 
     TRACE("(%p)->(%p, %p, %s, %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
 
     *ppvObj = NULL;
 
-    if (pbc || pmkToLeft)
+    if (pbc != old_bc)
+    {
+        FIXME("ignoring IBindCtx %p\n", pbc);
+        old_bc = pbc;
+    }
+
+    if (pmkToLeft)
         return MK_E_NOSTORAGE;
 
     if (IsEqualGUID(riid, &IID_IPropertyBag))
diff --git a/dlls/devenum/tests/devenum.c b/dlls/devenum/tests/devenum.c
index d8cd92f..d045be6 100644
--- a/dlls/devenum/tests/devenum.c
+++ b/dlls/devenum/tests/devenum.c
@@ -52,6 +52,8 @@ static void test_devenum(void)
     HRESULT res;
     ICreateDevEnum* create_devenum;
     IEnumMoniker* enum_moniker = NULL;
+    IBindCtx *bind_ctx = NULL;
+    struct category *used_category = NULL;
     int i;
 
     CoInitialize(NULL);
@@ -94,6 +96,8 @@ static void test_devenum(void)
                     {
                         trace("  %s\n", wine_dbgstr_w(V_UNION(&var, bstrVal)));
                         VariantClear(&var);
+                        if (!used_category)
+                            used_category = &am_categories[i];
                     }
                     else
                     {
@@ -111,6 +115,50 @@ static void test_devenum(void)
         trace("\n");
     }
 
+    /* IBindCtx is allowed in IMoniker_BindToStorage (IMediaCatMoniker_BindToStorage) */   
+    res = CreateBindCtx(0, &bind_ctx);
+    ok(res == S_OK, "Cannot create BindCtx: (res = 0x%x)\n", res);
+
+    if (used_category != NULL)
+    {
+        trace("%s (with IBindCtx %p)\n", used_category->name, bind_ctx);
+        res = ICreateDevEnum_CreateClassEnumerator(create_devenum, used_category->clsid, &enum_moniker, 0);
+        ok(SUCCEEDED(res), "%p: Cannot create enum moniker (res = %x)\n", bind_ctx, res);
+        if (res == S_OK)
+        {
+            IMoniker* moniker;
+            if (IEnumMoniker_Next(enum_moniker, 1, &moniker, NULL) == S_OK)
+            {
+                IPropertyBag* prop_bag = NULL;
+                VARIANT var;
+                HRESULT hr;
+
+                VariantInit(&var);
+                hr = IMoniker_BindToStorage(moniker, bind_ctx, NULL, &IID_IPropertyBag, (LPVOID*)&prop_bag);
+                ok(hr == S_OK, "%p: IMoniker_BindToStorage failed with error %x\n", bind_ctx, hr);
+
+                if (SUCCEEDED(hr))
+                {
+                    hr = IPropertyBag_Read(prop_bag, friendly_name, &var, NULL);
+                    ok((hr == S_OK) || broken(hr == 0x80070002), "%p: IPropertyBag_Read failed with error %x\n", bind_ctx, hr);
+
+                    if (SUCCEEDED(hr))
+                    {
+                        trace("  %s\n", wine_dbgstr_w(V_UNION(&var, bstrVal)));
+                        VariantClear(&var);
+                    }
+                }
+
+                if (prop_bag)
+                    IPropertyBag_Release(prop_bag);
+                IMoniker_Release(moniker);
+            }
+            IEnumMoniker_Release(enum_moniker);
+        }
+    }
+    if (bind_ctx)
+        IBindCtx_Release(bind_ctx);
+
     ICreateDevEnum_Release(create_devenum);
 
     CoUninitialize();
-- 
1.7.5.4




More information about the wine-patches mailing list