From 18517ca56f384ae8cb29edd008998b9b140f399d Mon Sep 17 00:00:00 2001 From: Stefan Leichter Date: Tue, 11 Oct 2005 20:27:27 +0000 Subject: [PATCH] Make user test loadable on NT4. --- dlls/user/tests/monitor.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/dlls/user/tests/monitor.c b/dlls/user/tests/monitor.c index 5765ee2aae9..fdff027802e 100644 --- a/dlls/user/tests/monitor.c +++ b/dlls/user/tests/monitor.c @@ -23,6 +23,21 @@ #include "wingdi.h" #include "winuser.h" +static HMODULE hdll; +static BOOL (WINAPI *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM); +static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); + +static void init_function_pointers(void) +{ + hdll = GetModuleHandleA("user32.dll"); + + if(hdll) + { + pEnumDisplayMonitors = (void*)GetProcAddress(hdll, "EnumDisplayMonitors"); + pGetMonitorInfoA = (void*)GetProcAddress(hdll, "GetMonitorInfoA"); + } +} + static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc, LPARAM lparam) { @@ -31,7 +46,7 @@ static BOOL CALLBACK monitor_enum_proc(HMONITOR hmon, HDC hdc, LPRECT lprc, mi.cbSize = sizeof(mi); - ok(GetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n"); + ok(pGetMonitorInfoA(hmon, (MONITORINFO*)&mi), "GetMonitorInfo failed\n"); if(mi.dwFlags == MONITORINFOF_PRIMARY) strcpy(primary, mi.szDevice); @@ -61,17 +76,19 @@ static void test_enumdisplaydevices(void) } ok(primary_num != -1, "Didn't get the primary device\n"); - ok(EnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name), - "EnumDisplayMonitors failed\n"); + if(pEnumDisplayMonitors && pGetMonitorInfoA) { + ok(pEnumDisplayMonitors(NULL, NULL, monitor_enum_proc, (LPARAM)primary_monitor_device_name), + "EnumDisplayMonitors failed\n"); - ok(!strcmp(primary_monitor_device_name, primary_device_name), - "monitor device name %s, device name %s\n", primary_monitor_device_name, - primary_device_name); + ok(!strcmp(primary_monitor_device_name, primary_device_name), + "monitor device name %s, device name %s\n", primary_monitor_device_name, + primary_device_name); + } } - START_TEST(monitor) { + init_function_pointers(); test_enumdisplaydevices(); }