在windows下判断当前系统是否处于全屏独占的模式下,通过这个能够获知用户是否在玩游戏,看电影等等。
 
 
 
 
以下采用的办法是通过判断屏幕的四角是否属于同一个窗口句柄。
 
 
InBlock.gif //检查当前是否有程序处于全屏独占模式 
InBlock.gif bool     IsFullScreen() 
InBlock.gif
InBlock.gif         //声明4个句柄,用于获取屏幕角落的的四个点 
InBlock.gif        HWND     pWnd1     =     NULL; 
InBlock.gif        HWND     pWnd2     =     NULL; 
InBlock.gif        HWND     pWnd3     =     NULL; 
InBlock.gif        HWND     pWnd4     =     NULL; 
InBlock.gif         //获取当前屏幕分辨率 Width 
InBlock.gif         int iCx=GetSystemMetrics(SM_CXSCREEN); 
InBlock.gif         //获取当前屏幕分辨率 Height 
InBlock.gif         int iCy=GetSystemMetrics(SM_CYSCREEN); 
InBlock.gif 
InBlock.gif        POINT     pt1; 
InBlock.gif        pt1.x     =     1; 
InBlock.gif        pt1.y     =     1; 
InBlock.gif        POINT     pt2; 
InBlock.gif        pt2.x     =     1; 
InBlock.gif        pt2.y     =     iCy-1; 
InBlock.gif        POINT     pt3; 
InBlock.gif        pt3.x     =     iCx-1; 
InBlock.gif        pt3.y     =     1; 
InBlock.gif        POINT     pt4; 
InBlock.gif        pt4.x     =     iCx-1; 
InBlock.gif        pt4.y     =     iCy-1; 
InBlock.gif 
InBlock.gif        pWnd1     =     WindowFromPoint(pt1); 
InBlock.gif        pWnd2     =     WindowFromPoint(pt2); 
InBlock.gif        pWnd3     =     WindowFromPoint(pt3); 
InBlock.gif        pWnd4     =     WindowFromPoint(pt4); 
InBlock.gif 
InBlock.gif         if (pWnd1     ==     pWnd2     &&     pWnd2     ==     pWnd3     &&     pWnd3     ==     pWnd4) 
InBlock.gif        { 
InBlock.gif                 return  true
InBlock.gif        } 
InBlock.gif         return  false
InBlock.gif
 
 
 
另外MSDN给出了一个官方的解决办法,暂时还没有测试。
 
shellapi.h

ABN_FULLSCREENAPP Notification


Notifies an appbar when a full-screen application is opening or closing. This notification is sent in the form of an application-defined message that is set by the  ABM_NEW message.
Syntax
ABN_FULLSCREENAPP 
    fOpen = (BOOL) lParam; 
			
Parameters
fOpen
A flag specifying whether a full-screen application is opening or closing. This parameter is TRUE if the application is opening or FALSE if it is closing.
Return Value
No return value.
Remarks
When a full-screen application is opening, an appbar must drop to the bottom of the z-order. When it is closing, the appbar should restore its z-order position.
Notification Requirements
Minimum DLL VersionNone
Custom ImplementationNo
Headershellapi.h
Minimum operating systemsWindows NT 3.51, Windows 95