0 out of 1 rated this helpful - Rate this topic

SetWindowDisplayAffinity function

Applies to: desktop apps only

Stores the display affinity setting in kernel mode on the hWnd associated with the window.

Syntax

BOOL WINAPI SetWindowDisplayAffinity(
  __in  HWND hWnd,
  __in  DWORD dwAffinity
);

Parameters

hWnd [in]

Type: HWND

A handle to the window.

dwAffinity [in]

Type: DWORD

The display affinity setting. This setting specifies where the window's contents are allowed to be displayed. If the value is set to 0x0000001, the window's contents can only be displayed on a monitor.

Return value

Type:

Type: BOOL

If the function succeeds, it returns TRUE; otherwise, it returns FALSE when, for example, the function call is made on a non top-level window. To get extended error information, call GetLastError.

Remarks

This function and GetWindowDisplayAffinity are designed to support the window content protection feature that is new to Windows 7. This feature enables applications to protect their own onscreen window content from being captured or copied through 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, for example where someone takes a photograph of the screen.

Requirements

Minimum supported client

Windows 7

Minimum supported server

Windows Server 2008 R2

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Reference
SetWindowDisplayAffinity
Conceptual
Windows

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
use the symbol WDA_MONITOR for the affinity value (2nd param)
WDA_NONE and WDA_MONITOR are the symbols that define the value 0 and 1 used with this API.