Platform SDK: Terminal Services

VirtualChannelOpen

The VirtualChannelOpen function opens the client end of a virtual channel.

Terminal Services provides a pointer to a VirtualChannelOpen function in the CHANNEL_ENTRY_POINTS structure passed to your VirtualChannelEntry entry point.

UINT VirtualChannelOpen (
  LPVOID pInitHandle,
  LPDWORD pOpenHandle,
  PCHAR pChannelName,
  PCHANNEL_OPEN_EVENT_FN pChannelOpenEventProc
);

Parameters

pInitHandle
[in] Handle to the client connection. This is the handle returned in the ppInitHandle parameter of the VirtualChannelInit function.
pOpenHandle
[out] Pointer to a variable that receives a handle that identifies the open virtual channel in subsequent calls to the VirtualChannelWrite and VirtualChannelClose functions.
pChannelName
[in] Pointer to a null-terminated string containing the name of the virtual channel to open. The name must have been registered when the client called the VirtualChannelInit function.
pChannelOpenEventProc
[in] Pointer to an application-defined VirtualChannelOpenEvent function that Terminal Services calls to notify the client DLL of events for this virtual channel.

Return Values

If the function succeeds, the return value is CHANNEL_RC_OK.

If an error occurs, the function returns one of the following values.

Value Meaning
CHANNEL_RC_ALREADY_OPEN The channel is already open.
CHANNEL_RC_BAD_CHANNEL_HANDLE The pOpenHandle parameter is not valid.
CHANNEL_RC_BAD_INIT_HANDLE The pInitHandle parameter is not valid.
CHANNEL_RC_BAD_PROC The pChannelOpenEventProc parameter is not valid.
CHANNEL_RC_NOT_CONNECTED The client has not connected to a terminal server.
CHANNEL_RC_UNKNOWN_CHANNEL_NAME The channel name specified by the pChannelName parameter is not registered by the client DLL or is otherwise invalid.

Remarks

The client DLL cannot call this function until the client has established a connection with a terminal server. Your VirtualChannelInitEvent function receives a CHANNEL_EVENT_CONNECTED notification when a terminal server connection is established.

Requirements

  Version: Requires RDP 5.0 client.
  Header: Declared in Cchannel.h.

See Also

Terminal Services API Overview, Terminal Services API Functions, VirtualChannelClose, VirtualChannelInit, VirtualChannelInitEvent, VirtualChannelOpenEvent, VirtualChannelWrite