Paul Vriens : shell32/tests: Use GetModuleHandle instead of
LoadLibrary.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Aug 16 05:38:31 CDT 2007
Module: wine
Branch: master
Commit: 444a8e5190a6b9c446f268a2172a3b6e8ff2a9d9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=444a8e5190a6b9c446f268a2172a3b6e8ff2a9d9
Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date: Wed Aug 15 21:00:06 2007 +0200
shell32/tests: Use GetModuleHandle instead of LoadLibrary.
---
dlls/shell32/tests/shellpath.c | 70 +++++++++++++++++++---------------------
dlls/shell32/tests/string.c | 4 +--
2 files changed, 34 insertions(+), 40 deletions(-)
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 402ff42..2821b4f 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -73,7 +73,7 @@ struct shellExpectedValues {
BYTE pidlType;
};
-static HMODULE hShell32;
+static HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO *);
static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
static HRESULT (WINAPI *pSHGetFolderLocation)(HWND, int, HANDLE, DWORD,
LPITEMIDLIST *);
@@ -152,45 +152,42 @@ static const struct shellExpectedValues optionalShellValues[] = {
static void loadShell32(void)
{
- hShell32 = LoadLibraryA("shell32");
- if (hShell32)
+ HMODULE hShell32 = GetModuleHandleA("shell32");
+
+#define GET_PROC(func) \
+ p ## func = (void*)GetProcAddress(hShell32, #func); \
+ if(!p ## func) \
+ trace("GetProcAddress(%s) failed\n", #func);
+
+ GET_PROC(DllGetVersion)
+ GET_PROC(SHGetFolderPathA)
+ GET_PROC(SHGetFolderLocation)
+ GET_PROC(SHGetSpecialFolderPathA)
+ GET_PROC(SHGetSpecialFolderLocation)
+ GET_PROC(ILFindLastID)
+ if (!pILFindLastID)
+ pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
+ GET_PROC(SHFileOperationA)
+ GET_PROC(SHGetMalloc)
+
+ ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
+ if (pSHGetMalloc)
{
- HRESULT (WINAPI *pDllGetVersion)(DLLVERSIONINFO *);
-
- pSHGetFolderPathA = (void *)GetProcAddress(hShell32,
- "SHGetFolderPathA");
- pSHGetFolderLocation = (void *)GetProcAddress(hShell32,
- "SHGetFolderLocation");
- pSHGetSpecialFolderPathA = (void *)GetProcAddress(hShell32,
- "SHGetSpecialFolderPathA");
- pSHGetSpecialFolderLocation = (void *)GetProcAddress(hShell32,
- "SHGetSpecialFolderLocation");
- pDllGetVersion = (void *)GetProcAddress(hShell32, "DllGetVersion");
- pILFindLastID = (void *)GetProcAddress(hShell32, "ILFindLastID");
- if (!pILFindLastID)
- pILFindLastID = (void *)GetProcAddress(hShell32, (LPCSTR)16);
- pSHFileOperationA = (void *)GetProcAddress(hShell32,
- "SHFileOperationA");
- pSHGetMalloc = (void *)GetProcAddress(hShell32, "SHGetMalloc");
-
- ok(pSHGetMalloc != NULL, "shell32 is missing SHGetMalloc\n");
- if (pSHGetMalloc)
- {
- HRESULT hr = pSHGetMalloc(&pMalloc);
+ HRESULT hr = pSHGetMalloc(&pMalloc);
- ok(SUCCEEDED(hr), "SHGetMalloc failed: 0x%08x\n", hr);
- ok(pMalloc != NULL, "SHGetMalloc returned a NULL IMalloc\n");
- }
+ ok(SUCCEEDED(hr), "SHGetMalloc failed: 0x%08x\n", hr);
+ ok(pMalloc != NULL, "SHGetMalloc returned a NULL IMalloc\n");
+ }
- if (pDllGetVersion)
- {
- shellVersion.cbSize = sizeof(shellVersion);
- pDllGetVersion(&shellVersion);
- if (winetest_interactive)
- printf("shell32 version is %d.%d\n",
- shellVersion.dwMajorVersion, shellVersion.dwMinorVersion);
- }
+ if (pDllGetVersion)
+ {
+ shellVersion.cbSize = sizeof(shellVersion);
+ pDllGetVersion(&shellVersion);
+ if (winetest_interactive)
+ printf("shell32 version is %d.%d\n",
+ shellVersion.dwMajorVersion, shellVersion.dwMinorVersion);
}
+#undef GET_PROC
}
#ifndef CSIDL_PROFILES
@@ -892,7 +889,6 @@ START_TEST(shellpath)
if (!init()) return;
loadShell32();
- if (!hShell32) return;
if (myARGC >= 3)
doChild(myARGV[2]);
diff --git a/dlls/shell32/tests/string.c b/dlls/shell32/tests/string.c
index acd3101..c748f35 100644
--- a/dlls/shell32/tests/string.c
+++ b/dlls/shell32/tests/string.c
@@ -100,9 +100,7 @@ START_TEST(string)
{
CoInitialize(0);
- hShell32 = LoadLibraryA("shell32.dll");
- if (!hShell32)
- return;
+ hShell32 = GetModuleHandleA("shell32.dll");
pStrRetToStrNAW = (void*)GetProcAddress(hShell32, (LPSTR)96);
if (pStrRetToStrNAW)
More information about the wine-cvs
mailing list