Dynamically load StrRetToBufW(). This lets shell32_test.exe run on

systems that have version 4.72 of shlwapi.dll.
This commit is contained in:
Francois Gouget 2005-08-16 19:29:40 +00:00 committed by Alexandre Julliard
parent 1fddb3ff20
commit 7f65f6a4e2
1 changed files with 23 additions and 9 deletions

View File

@ -43,18 +43,26 @@ static IMalloc *ppM;
static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*); static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*);
static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL); static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL);
static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
static void init_function_pointers(void) static void init_function_pointers(void)
{ {
HMODULE hmod = GetModuleHandleA("shell32.dll"); HMODULE hmod;
HRESULT hr; HRESULT hr;
hmod = GetModuleHandleA("shell32.dll");
if(hmod) if(hmod)
{ {
pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent"); pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent");
pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW"); pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW");
} }
hmod = GetModuleHandleA("shlwapi.dll");
if(hmod)
{
pStrRetToBufW = (void*)GetProcAddress(hmod, "StrRetToBufW");
}
hr = SHGetMalloc(&ppM); hr = SHGetMalloc(&ppM);
ok(hr == S_OK, "SHGetMalloc failed %08lx\n", hr); ok(hr == S_OK, "SHGetMalloc failed %08lx\n", hr);
} }
@ -369,10 +377,13 @@ static void test_GetDisplayName(void)
IShellFolder_Release(psfPersonal); IShellFolder_Release(psfPersonal);
return; return;
} }
hr = StrRetToBufW(&strret, pidlLast, wszTestFile2, MAX_PATH); if (pStrRetToBufW)
ok (SUCCEEDED(hr), "StrRetToBufW failed! hr = %08lx\n", hr); {
ok (!lstrcmpiW(wszTestFile, wszTestFile2), "GetDisplayNameOf returns incorrect path!\n"); 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(psfDesktop);
IShellFolder_Release(psfPersonal); IShellFolder_Release(psfPersonal);
@ -661,10 +672,13 @@ static void test_SHGetPathFromIDList(void)
IMalloc_Free(ppM, pidlTestFile); IMalloc_Free(ppM, pidlTestFile);
return; return;
} }
StrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH); if (pStrRetToBufW)
ok(0 == lstrcmpW(wszFileName, wszPath), {
"Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) " pStrRetToBufW(&strret, pidlTestFile, wszPath, MAX_PATH);
"returned incorrect path for file placed on desktop\n"); ok(0 == lstrcmpW(wszFileName, wszPath),
"Desktop->GetDisplayNameOf(pidlTestFile, SHGDN_FORPARSING) "
"returned incorrect path for file placed on desktop\n");
}
result = SHGetPathFromIDListW(pidlTestFile, wszPath); result = SHGetPathFromIDListW(pidlTestFile, wszPath);
ok(result, "SHGetPathFromIDListW failed! Last error: %08lx\n", GetLastError()); ok(result, "SHGetPathFromIDListW failed! Last error: %08lx\n", GetLastError());