# NNS_McsOpenStreamEx

## C Specification

      #include <nnsys/mcs.h>

      struct NNSMcsStreamInfo
      {
      DWORD   structBytes;
      DWORD   deviceType;
      };

      HANDLE NNS_McsOpenStreamEx(
      USHORT            channel,
      DWORD             flags,
      NNSMcsStreamInfo* pStreamInfo);

## Arguments

channel | Value for identifying a stream. You can specify in the range 0-0x3FFF. 0x4000-0x7FFF is reserved for NITRO-System applications. 0x8000-0xFFFF is reserved for the MCS system.
flags | Flags specified when stream is opened. (For details, see the description)
pStreamInfo | Pointer to the structure storing supplemental information related to the opened stream.

## Return Values

If the stream is successfully opened, the function returns the stream's handle. If the process fails, the function returns `INVALID_HANDLE_VALUE`. You can get details about the error using `GetLastError()`.

## Description

Opens a stream for Multiple Channel Stream. Stream is actually a pipe that has the message type of the Win32 system, and the return value becomes a handle for this pipe that has a name. The function `NNS_McsOpenStream` opens the pipe that has the message type name, and registers the value that identifies the stream specified with the argument channel to the MCS server.

To read and write to the stream, use `ReadFile(Ex)` and `WriteFile(Ex)` of Win32 API.

With the argument flag, 0 or the values shown below can be specified. This value is passed to the sixth argument (`dwFlagsAndAttributes`) in `CreateFile` of the Win32 API.

FILE_FLAG_OVERLAPPED | Inputs/outputs asynchronously (overlapped I/O). For details, see the explanation of `CreateFile` in the Win32 API.

Sets supplemental information related to the opened stream gets stored in the `NNSMcsStreamInfo` structure specified by `pStreamInfo`. Details about the `NNSMcsStreamInfo` structure members are described below.

structBytes | Indicates the size of the structure. Set `sizeof(NNSMcsStreamInfo)` before calling the function.
deviceType | A value indicating the device type is set here.

Here is a list of the device types that can be set in `deviceType`:

NNS_MCS_DEVICE_TYPE_UNKNOWN | Unknown device
NNS_MCS_DEVICE_TYPE_NITRO_DEBUGGER | IS-NITRO-EMULATOR
NNS_MCS_DEVICE_TYPE_NITRO_UIC | IS-NITRO-UIC
NNS_MCS_DEVICE_TYPE_ENSATA | ensata

## See Also

`NNS_McsOpenStream`

## Revision History

01/11/2005 Added the description. Deleted IS-CGB-EMULATOR from the device type and added ensata.
10/08/2004 Added a description of the channel argument.
07/20/2004 Initial version.