GetWindowDisplayAffinity function (winuser.h)
Retrieves the current display affinity setting, from any process, for a given window.
Syntax
BOOL GetWindowDisplayAffinity(
[in] HWND hWnd,
[out] DWORD *pdwAffinity
);
Parameters
[in] hWnd
Type: HWND
A handle to the window.
[out] pdwAffinity
Type: DWORD*
A pointer to a variable that receives the display affinity setting. See SetWindowDisplayAffinity for a list of affinity settings and their meanings.
Return value
Type: BOOL
This function succeeds only when the window is layered and Desktop Windows Manager is composing the desktop. If this function succeeds, it returns TRUE; otherwise, it returns FALSE. To get extended error information, call GetLastError.
Remarks
This function and SetWindowDisplayAffinity are designed to support the window content protection feature unique to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied via a specific set of public operating system features and APIs. However, it works only when the Desktop Window Manager (DWM) is composing the desktop.
It is important to note that unlike a security feature or an implementation of Digital Rights Management (DRM), there is no guarantee that using SetWindowDisplayAffinity and GetWindowDisplayAffinity, and other necessary functions such as DwmIsCompositionEnabled, will strictly protect windowed content, as in the case where someone takes a photograph of the screen.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 7 [desktop apps only] |
Minimum supported server | Windows Server 2008 R2 [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-window-l1-1-1 (introduced in Windows 8.1) |
See also
Conceptual