[PATCH] Implement IFolderView::GetFolder() for IID_IShellFolder

Nikolay Sivov nsivov at codeweavers.com
Sat Mar 6 14:55:55 CST 2010


---
 dlls/shell32/shlview.c       |   16 +++++++++++++---
 dlls/shell32/tests/shlview.c |   23 ++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 4 deletions(-)

diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index f718c2b..af14604 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -2711,9 +2711,19 @@ static HRESULT WINAPI IFView_SetCurrentViewMode(IFolderView *iface, UINT mode)
 
 static HRESULT WINAPI IFView_GetFolder(IFolderView *iface, REFIID riid, void **ppv)
 {
-	IShellViewImpl *This = impl_from_IFolderView(iface);
-	FIXME("(%p)->(%s, %p), stub\n", This, debugstr_guid(riid), ppv);
-	return E_NOTIMPL;
+    IShellViewImpl *This = impl_from_IFolderView(iface);
+
+    TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), ppv);
+
+    if (!ppv) return E_POINTER;
+
+    if (IsEqualIID(riid, &IID_IShellFolder))
+    {
+        *ppv = This->pSFParent;
+        return S_OK;
+    }
+
+    return E_NOINTERFACE;
 }
 
 static HRESULT WINAPI IFView_Item(IFolderView *iface, int index, PITEMID_CHILD *ppidl)
diff --git a/dlls/shell32/tests/shlview.c b/dlls/shell32/tests/shlview.c
index 2cd4c4b..c8cd4cf 100644
--- a/dlls/shell32/tests/shlview.c
+++ b/dlls/shell32/tests/shlview.c
@@ -347,7 +347,7 @@ if (0)
 
 static void test_IFolderView(void)
 {
-    IShellFolder *desktop;
+    IShellFolder *desktop, *folder;
     FOLDERSETTINGS settings;
     IShellView *view;
     IShellBrowser *browser;
@@ -356,6 +356,7 @@ static void test_IFolderView(void)
     HRESULT hr;
     INT ret;
     POINT pt;
+    LONG ref1, ref2;
     RECT r;
 
     hr = SHGetDesktopFolder(&desktop);
@@ -448,6 +449,26 @@ if (0)
     ok_sequence(sequences, LISTVIEW_SEQ_INDEX, folderview_getfocused_seq,
                                   "IFolderView::GetFocusedItem", FALSE);
 
+    /* IFolderView::GetFolder, just return pointer */
+if (0)
+{
+    /* crashes on XP */
+    hr = IFolderView_GetFolder(fv, NULL, (void**)&folder);
+    hr = IFolderView_GetFolder(fv, NULL, NULL);
+}
+
+    hr = IFolderView_GetFolder(fv, &IID_IShellFolder, NULL);
+    ok(hr == E_POINTER, "got (0x%08x)\n", hr);
+
+    ref1 = IShellFolder_AddRef(desktop);
+    IShellFolder_Release(desktop);
+    hr = IFolderView_GetFolder(fv, &IID_IShellFolder, (void**)&folder);
+    ok(hr == S_OK, "got (0x%08x)\n", hr);
+    ref2 = IShellFolder_AddRef(desktop);
+    IShellFolder_Release(desktop);
+    ok(ref1 == ref2, "expected same refcount, got %d\n", ref2);
+    ok(desktop == folder, "\n");
+
     IShellBrowser_Release(browser);
     IFolderView_Release(fv);
     IShellView_Release(view);
-- 
1.5.6.5


--=-ZbaKkRRBotdVYnBCW3uc--




More information about the wine-patches mailing list