Paul Vriens : setupapi/tests: Use GetModuleHandleA instead of LoadLibraryA.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 31 07:54:59 CDT 2007


Module: wine
Branch: master
Commit: c0cc85f78e748ae7cd9114f7053c45b588922c93
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c0cc85f78e748ae7cd9114f7053c45b588922c93

Author: Paul Vriens <paul.vriens.wine at gmail.com>
Date:   Tue Jul 31 09:30:55 2007 +0200

setupapi/tests: Use GetModuleHandleA instead of LoadLibraryA.

---

 dlls/setupapi/tests/devinst.c     |   13 ++++---------
 dlls/setupapi/tests/parser.c      |    4 +---
 dlls/setupapi/tests/query.c       |   21 +++++++++------------
 dlls/setupapi/tests/stringtable.c |    6 +-----
 4 files changed, 15 insertions(+), 29 deletions(-)

diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
index d0756b7..6232105 100644
--- a/dlls/setupapi/tests/devinst.c
+++ b/dlls/setupapi/tests/devinst.c
@@ -39,14 +39,11 @@ static HKEY     (WINAPI *pSetupDiOpenClassRegKeyExA)(GUID*,REGSAM,DWORD,PCSTR,PV
 
 static void init_function_pointers(void)
 {
-    hSetupAPI = LoadLibraryA("setupapi.dll");
+    hSetupAPI = GetModuleHandleA("setupapi.dll");
 
-    if (hSetupAPI)
-    {
-        pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW");
-        pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList");
-        pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA");
-    }
+    pSetupDiCreateDeviceInfoListExW = (void *)GetProcAddress(hSetupAPI, "SetupDiCreateDeviceInfoListExW");
+    pSetupDiDestroyDeviceInfoList = (void *)GetProcAddress(hSetupAPI, "SetupDiDestroyDeviceInfoList");
+    pSetupDiOpenClassRegKeyExA = (void *)GetProcAddress(hSetupAPI, "SetupDiOpenClassRegKeyExA");
 }
 
 static void test_SetupDiCreateDeviceInfoListEx(void) 
@@ -129,8 +126,6 @@ static void test_SetupDiOpenClassRegKeyExA(void)
 START_TEST(devinst)
 {
     init_function_pointers();
-    if (!hSetupAPI)
-        return;
 
     if (pSetupDiCreateDeviceInfoListExW && pSetupDiDestroyDeviceInfoList)
         test_SetupDiCreateDeviceInfoListEx();
diff --git a/dlls/setupapi/tests/parser.c b/dlls/setupapi/tests/parser.c
index 2aaaa5e..4c1043e 100644
--- a/dlls/setupapi/tests/parser.c
+++ b/dlls/setupapi/tests/parser.c
@@ -36,9 +36,7 @@ static LPCWSTR (WINAPI *pSetupGetField)(PINFCONTEXT,DWORD);
 
 static void init_function_pointers(void)
 {
-    hSetupAPI = LoadLibraryA("setupapi.dll");
-    if (!hSetupAPI)
-        return;
+    hSetupAPI = GetModuleHandleA("setupapi.dll");
 
     pSetupGetField = (void *)GetProcAddress(hSetupAPI, "pSetupGetField"); 
 }
diff --git a/dlls/setupapi/tests/query.c b/dlls/setupapi/tests/query.c
index 39c91c7..ef2f9f5 100644
--- a/dlls/setupapi/tests/query.c
+++ b/dlls/setupapi/tests/query.c
@@ -38,18 +38,15 @@ CHAR WIN_DIR[MAX_PATH];
 
 static void init_function_pointers(void)
 {
-    hSetupAPI = LoadLibraryA("setupapi.dll");
-
-    if (hSetupAPI)
-    {
-        pSetupCloseInfFile = (void *)GetProcAddress(hSetupAPI, "SetupCloseInfFile");
-        pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA");
-        pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA");
-        pSetupQueryInfFileInformationA = (void *)GetProcAddress(hSetupAPI, "SetupQueryInfFileInformationA");
-        pSetupGetSourceFileLocationA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceFileLocationA");
-        pSetupGetSourceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceInfoA");
-        pSetupGetTargetPathA = (void *)GetProcAddress(hSetupAPI, "SetupGetTargetPathA");
-    }
+    hSetupAPI = GetModuleHandleA("setupapi.dll");
+
+    pSetupCloseInfFile = (void *)GetProcAddress(hSetupAPI, "SetupCloseInfFile");
+    pSetupGetInfInformationA = (void *)GetProcAddress(hSetupAPI, "SetupGetInfInformationA");
+    pSetupOpenInfFileA = (void *)GetProcAddress(hSetupAPI, "SetupOpenInfFileA");
+    pSetupQueryInfFileInformationA = (void *)GetProcAddress(hSetupAPI, "SetupQueryInfFileInformationA");
+    pSetupGetSourceFileLocationA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceFileLocationA");
+    pSetupGetSourceInfoA = (void *)GetProcAddress(hSetupAPI, "SetupGetSourceInfoA");
+    pSetupGetTargetPathA = (void *)GetProcAddress(hSetupAPI, "SetupGetTargetPathA");
 }
 
 static void get_directories(void)
diff --git a/dlls/setupapi/tests/stringtable.c b/dlls/setupapi/tests/stringtable.c
index 59e49c0..d48984a 100644
--- a/dlls/setupapi/tests/stringtable.c
+++ b/dlls/setupapi/tests/stringtable.c
@@ -59,9 +59,7 @@ HANDLE table, table2;  /* Handles pointing to our tables */
 
 static void load_it_up(void)
 {
-    hdll = LoadLibraryA("setupapi.dll");
-    if (!hdll)
-        return;
+    hdll = GetModuleHandleA("setupapi.dll");
 
     pStringTableInitialize = (void*)GetProcAddress(hdll, "StringTableInitialize");
     if (!pStringTableInitialize)
@@ -192,6 +190,4 @@ START_TEST(stringtable)
     /* assume we can always distroy */
     pStringTableDestroy(table);
     pStringTableDestroy(table2);
-
-    FreeLibrary(hdll);
 }




More information about the wine-cvs mailing list