shell32/tests: Use GetProcAddress() on SHGetPathFromIDListW() because it is missing on Windows 95.

This commit is contained in:
Francois Gouget 2007-12-18 10:01:05 +01:00 committed by Alexandre Julliard
parent 3874c55cc4
commit d22568d094
1 changed files with 28 additions and 19 deletions

View File

@ -43,6 +43,7 @@
static IMalloc *ppM;
static HRESULT (WINAPI *pSHBindToParent)(LPCITEMIDLIST, REFIID, LPVOID*, LPCITEMIDLIST*);
static BOOL (WINAPI *pSHGetPathFromIDListW)(LPCITEMIDLIST,LPWSTR);
static BOOL (WINAPI *pSHGetSpecialFolderPathW)(HWND, LPWSTR, int, BOOL);
static HRESULT (WINAPI *pStrRetToBufW)(STRRET*,LPCITEMIDLIST,LPWSTR,UINT);
static LPITEMIDLIST (WINAPI *pILFindLastID)(LPCITEMIDLIST);
@ -56,6 +57,7 @@ static void init_function_pointers(void)
hmod = GetModuleHandleA("shell32.dll");
pSHBindToParent = (void*)GetProcAddress(hmod, "SHBindToParent");
pSHGetPathFromIDListW = (void*)GetProcAddress(hmod, "SHGetPathFromIDListW");
pSHGetSpecialFolderPathW = (void*)GetProcAddress(hmod, "SHGetSpecialFolderPathW");
pILFindLastID = (void *)GetProcAddress(hmod, (LPCSTR)16);
pILFree = (void*)GetProcAddress(hmod, (LPSTR)155);
@ -363,10 +365,10 @@ static void test_GetDisplayName(void)
static const WCHAR wszDirName[] = { 'w','i','n','e','t','e','s','t',0 };
/* I'm trying to figure if there is a functional difference between calling
* SHGetPathFromIDList and calling GetDisplayNameOf(SHGDN_FORPARSING) after
* SHGetPathFromIDListW and calling GetDisplayNameOf(SHGDN_FORPARSING) after
* binding to the shellfolder. One thing I thought of was that perhaps
* SHGetPathFromIDList would be able to get the path to a file, which does
* not exist anymore, while the other method would'nt. It turns out there's
* SHGetPathFromIDListW would be able to get the path to a file, which does
* not exist anymore, while the other method wouldn't. It turns out there's
* no functional difference in this respect.
*/
@ -461,9 +463,12 @@ static void test_GetDisplayName(void)
RemoveDirectoryA(szTestDir);
/* SHGetPathFromIDListW still works, although the file is not present anymore. */
result = SHGetPathFromIDListW(pidlTestFile, wszTestFile2);
ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n");
if (pSHGetPathFromIDListW)
{
result = pSHGetPathFromIDListW(pidlTestFile, wszTestFile2);
ok (result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
ok (!lstrcmpiW(wszTestFile, wszTestFile2), "SHGetPathFromIDListW returns incorrect path!\n");
}
if(!pSHBindToParent) return;
@ -793,26 +798,30 @@ static void test_SHGetPathFromIDList(void)
HMODULE hShell32;
LPITEMIDLIST pidlPrograms;
if(!pSHGetSpecialFolderPathW) return;
if(!pSHGetPathFromIDListW || !pSHGetSpecialFolderPathW)
{
skip("SHGetPathFromIDListW() or SHGetSpecialFolderPathW() is missing\n");
return;
}
/* Calling SHGetPathFromIDList with no pidl should return the empty string */
/* Calling SHGetPathFromIDListW with no pidl should return the empty string */
wszPath[0] = 'a';
wszPath[1] = '\0';
result = SHGetPathFromIDListW(NULL, wszPath);
result = pSHGetPathFromIDListW(NULL, wszPath);
ok(!result, "Expected failure\n");
ok(!wszPath[0], "Expected empty string\n");
/* Calling SHGetPathFromIDList with an empty pidl should return the desktop folder's path. */
/* Calling SHGetPathFromIDListW with an empty pidl should return the desktop folder's path. */
result = pSHGetSpecialFolderPathW(NULL, wszDesktop, CSIDL_DESKTOP, FALSE);
ok(result, "SHGetSpecialFolderPathW(CSIDL_DESKTOP) failed! Last error: %u\n", GetLastError());
if (!result) return;
result = SHGetPathFromIDListW(pidlEmpty, wszPath);
result = pSHGetPathFromIDListW(pidlEmpty, wszPath);
ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
if (!result) return;
ok(!lstrcmpiW(wszDesktop, wszPath), "SHGetPathFromIDList didn't return desktop path for empty pidl!\n");
ok(!lstrcmpiW(wszDesktop, wszPath), "SHGetPathFromIDListW didn't return desktop path for empty pidl!\n");
/* MyComputer does not map to a filesystem path. SHGetPathFromIDList should fail. */
/* MyComputer does not map to a filesystem path. SHGetPathFromIDListW should fail. */
hr = SHGetDesktopFolder(&psfDesktop);
ok (SUCCEEDED(hr), "SHGetDesktopFolder failed! hr = %08x\n", hr);
if (FAILED(hr)) return;
@ -827,9 +836,9 @@ static void test_SHGetPathFromIDList(void)
SetLastError(0xdeadbeef);
wszPath[0] = 'a';
wszPath[1] = '\0';
result = SHGetPathFromIDListW(pidlMyComputer, wszPath);
ok (!result, "SHGetPathFromIDList succeeded where it shouldn't!\n");
ok (GetLastError()==0xdeadbeef, "SHGetPathFromIDList shouldn't set last error! Last error: %u\n", GetLastError());
result = pSHGetPathFromIDListW(pidlMyComputer, wszPath);
ok (!result, "SHGetPathFromIDListW succeeded where it shouldn't!\n");
ok (GetLastError()==0xdeadbeef, "SHGetPathFromIDListW shouldn't set last error! Last error: %u\n", GetLastError());
ok (!wszPath[0], "Expected empty path\n");
if (result) {
IShellFolder_Release(psfDesktop);
@ -881,7 +890,7 @@ static void test_SHGetPathFromIDList(void)
"returned incorrect path for file placed on desktop\n");
}
result = SHGetPathFromIDListW(pidlTestFile, wszPath);
result = pSHGetPathFromIDListW(pidlTestFile, wszPath);
ok(result, "SHGetPathFromIDListW failed! Last error: %u\n", GetLastError());
IMalloc_Free(ppM, pidlTestFile);
if (!result) return;
@ -896,9 +905,9 @@ static void test_SHGetPathFromIDList(void)
ok(SUCCEEDED(hr), "SHGetFolderLocation failed: 0x%08x\n", hr);
SetLastError(0xdeadbeef);
result = SHGetPathFromIDListW(pidlPrograms, wszPath);
result = pSHGetPathFromIDListW(pidlPrograms, wszPath);
IMalloc_Free(ppM, pidlPrograms);
ok(result, "SHGetPathFromIDList failed\n");
ok(result, "SHGetPathFromIDListW failed\n");
}
static void test_EnumObjects_and_CompareIDs(void)