Export (0) Print
Expand All
Expand Minimize

WTSRegisterSessionNotificationEx function

Registers the specified window to receive session change notifications.

Syntax


BOOL WTSRegisterSessionNotificationEx(
  _In_  HANDLE hServer,
  _In_  HWND hWnd,
  _In_  DWORD dwFlags
);

Parameters

hServer [in]

Handle of the server returned from WTSOpenServer or WTS_CURRENT_SERVER.

hWnd [in]

Handle of the window to receive session change notifications.

dwFlags [in]

Specifies which session notifications are to be received. This parameter can only be NOTIFY_FOR_THIS_SESSION if hServer is a remote server.

ValueMeaning
NOTIFY_FOR_THIS_SESSION
0

Only session notifications involving the session attached to by the window identified by the hWnd parameter value are to be received.

NOTIFY_FOR_ALL_SESSIONS
1

All session notifications are to be received.

 

Return value

If the function succeeds, the return value is TRUE. Otherwise, it is FALSE. To get extended error information, call GetLastError.

Remarks

If this function is called before the dependent services of Remote Desktop Services have started, an RPC_S_INVALID_BINDING error code may be returned. When the "Global\\TermSrvReadyEvent" global event is set, all dependent services have started and this function can be successfully called.

Session change notifications are sent in the form of a WM_WTSSESSION_CHANGE message. These notifications are sent only to the windows that have registered for them using this function.

When a window no longer requires these notifications, it must call WTSUnRegisterSessionNotificationEx before being destroyed. For every call to this function, there must be a corresponding call to WTSUnRegisterSessionNotificationEx.

If the window handle passed in this function is already registered, the value of the dwFlags parameter is ignored.

To receive session change notifications from a service, use the HandlerEx function.

Requirements

Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2008

Header

Wtsapi32.h

Library

Wtsapi32.lib

DLL

Wtsapi32.dll

See also

HandlerEx
WTSUnRegisterSessionNotificationEx
WTSGetActiveConsoleSessionId
WTSOpenServer
WM_WTSSESSION_CHANGE
WTSSESSION_NOTIFICATION

 

 

Show:
© 2014 Microsoft