From 454c1b7599cfa537980cc5bf3203b4ccd469c7cf Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Thu, 10 Mar 2005 17:17:35 +0000 Subject: [PATCH] Implement a test for the desktop visibility based on the MSDN article pointed out by Robert Shearman. --- programs/winetest/main.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/programs/winetest/main.c b/programs/winetest/main.c index 9167b335eed..30f1cabb84c 100644 --- a/programs/winetest/main.c +++ b/programs/winetest/main.c @@ -30,6 +30,7 @@ #include #include +#include #include #ifdef HAVE_UNISTD_H # include @@ -68,23 +69,21 @@ static int running_under_wine () static int running_on_visible_desktop () { - BOOL visible; - HWND desktop; - HDC hdc; - HRGN hrgn; - RECT rc; + FARPROC pGetProcessWindowStation = GetProcAddress(GetModuleHandle("user32.dll"), "GetProcessWindowStation"); - desktop = GetDesktopWindow(); - hdc = GetDC(desktop); - hrgn = CreateRectRgn(0, 0, 0, 0); - GetRandomRgn(hdc, hrgn, SYSRGN); + if (pGetProcessWindowStation) + { + DWORD len; + HWINSTA wstation; + USEROBJECTFLAGS uoflags; + FARPROC pGetUserObjectInformationA = GetProcAddress(GetModuleHandle("user32.dll"), "GetUserObjectInformationA"); - visible = GetRgnBox(hrgn, &rc) != NULLREGION; - - DeleteObject(hrgn); - ReleaseDC(desktop, hdc); - - return visible; + wstation = (HWINSTA)pGetProcessWindowStation(); + assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len)); + return (uoflags.dwFlags & WSF_VISIBLE) != 0; + } + else + return IsWindowVisible(GetDesktopWindow()); } void print_version ()