WTSConnectSessionA function (wtsapi32.h)

Connects a Remote Desktop Services session to an existing session on the local computer.

Syntax

BOOL WTSConnectSessionA(
  [in] ULONG LogonId,
  [in] ULONG TargetLogonId,
  [in] PSTR  pPassword,
  [in] BOOL  bWait
);

Parameters

[in] LogonId

The logon ID of the session to connect to. The user of that session must have permissions to connect to an existing session. The output of this session will be routed to the session identified by the TargetLogonId parameter.

This can be LOGONID_CURRENT to use the current session.

[in] TargetLogonId

The logon ID of the session to receive the output of the session represented by the LogonId parameter. The output of the session identified by the LogonId parameter will be routed to this session.

This can be LOGONID_CURRENT to use the current session.

[in] pPassword

A pointer to the password for the user account that is specified in the LogonId parameter. The value of pPassword can be an empty string if the caller is logged on using the same domain name and user name as the logon ID. The value of pPassword cannot be NULL.

[in] bWait

Indicates whether the operation is synchronous. Specify TRUE to wait for the operation to complete, or FALSE to return immediately.

Return value

If the function succeeds, the return value is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Either the LogonId or TargetLogonId parameter can be LOGONID_CURRENT, but not both.

Note

The wtsapi32.h header defines WTSConnectSession as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

   
Minimum supported client Windows Vista with SP1
Minimum supported server Windows Server 2008
Target Platform Windows
Header wtsapi32.h
Library Wtsapi32.lib
DLL Wtsapi32.dll