Get shlfolder test running with shell32 4.0

Francois Gouget fgouget at codeweavers.com
Tue Aug 16 10:59:31 CDT 2005


Alexandre Julliard wrote:
> Francois Gouget <fgouget at codeweavers.com> writes:
> 
>>Version 4.0 of the shell32 dll does not export StrRetToBufW().
> 
> Other shell32 versions don't either, since StrRetToBufW is in shlwapi ;-)

Whoops, right. The library giving me trouble is shlwapi.dll version 
4.72.3110.0. Here's a corrected patch.

Changelog:

   * dlls/shell32/tests/shlfolder.c

    Francois Gouget <fgouget at codeweavers.com>
    Dynamically load StrRetToBufW().
    This lets shell32_test.exe run on systems that have version 4.72 of 
shlwapi.dll.


-- 
Francois Gouget
fgouget at codeweavers.com

-------------- next part --------------
Index: dlls/shell32/tests/shlfolder.c
===================================================================
RCS file: /var/cvs/wine/dlls/shell32/tests/shlfolder.c,v
retrieving revision 1.30
diff -u -p -r1.30 shlfolder.c
--- dlls/shell32/tests/shlfolder.c	15 Aug 2005 09:40:45 -0000	1.30
+++ dlls/shell32/tests/shlfolder.c	16 Aug 2005 15:54:57 -0000
@@ -43,18 +43,26 @@ static IMalloc *ppM;
 
 static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*);
 static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL);
+static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
 
 static void init_function_pointers(void)
 {
-    HMODULE hmod = GetModuleHandleA("shell32.dll");
+    HMODULE hmod;
     HRESULT hr;
 
+    hmod = GetModuleHandleA("shell32.dll");
     if(hmod)
     {
         pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent");
         pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW");
     }
 
+    hmod = GetModuleHandleA("shlwapi.dll");
+    if(hmod)
+    {
+        pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW");
+    }
+
     hr = SHGetMalloc(&ppM);
     ok(hr == S_OK, "SHGetMalloc failed %08lx\n", hr);
 }
@@ -369,10 +383,13 @@ static void test_GetDisplayName(void)
         IShellFolder_Release(psfPersonal);
         return;
     }
-    
-    hr = StrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH);
-    ok (SUCCEEDED(hr), "StrRetToBufW failed! hr = %08lx\n", hr);
-    ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n");
+
+    if (pStrRetToBufW)
+    {
+        hr = pStrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH);
+        ok (SUCCEEDED(hr), "StrRetToBufW failed! hr = %08lx\n", hr);
+        ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n");
+    }
     
     IShellFolder_Release(psfDesktop);
     IShellFolder_Release(psfPersonal);
@@ -661,10 +678,13 @@ static void test_SHGetPathFromIDList(voi
         IMalloc_Free(ppM, pidlTestFile);
         return;
     }
-    StrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH);
-    ok(0 == lstrcmpW(wszFileName, wszPath), 
-        "Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) "
-        "returned incorrect path for file placed on desktop\n");
+    if (pStrRetToBufW)
+    {
+        pStrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH);
+        ok(0 == lstrcmpW(wszFileName, wszPath), 
+           "Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) "
+           "returned incorrect path for file placed on desktop\n");
+    }
 
     result = SHGetPathFromIDListW(pidlTestFile, wszPath);
     ok(result, "SHGetPathFromIDListW failed! Last error: %08lx\n", GetLastError());


More information about the wine-patches mailing list