BuildCommDCB

  BOOL BuildCommDCB(lpszDef, lpdcb)    
  LPSTR lpszDef; /* address of device-control string */
  LPDCB lpdcb; /* address of device-control block */

The BuildCommDCB function translates a device definition string into appropriate serial device-control block codes.

Parameters

lpszDef

Points to a null-terminated string that specifies device-control information. The string must have the same form as the MS-DOS MODE command-line parameter.

lpdcb

Points to the DCB structure that is to receive the translated string. The structure defines the control setting for the serial-communication device.

The DCB structure has the following form:

typedef struct _DCB { /* dcb */

DWORD DCBlength; /* sizeof(DCB) */

DWORD BaudRate; /* Baudrate at which running */

DWORD fBinary: 1; /* Binary Mode (skip EOF check) */

DWORD fParity: 1; /* Enable parity checking */

DWORD fOutxCtsFlow:1; /* CTS handshaking on output */

DWORD fOutxDsrFlow:1; /* DSR handshaking on output */

DWORD fDtrControl:2; /* DTR Flow control */

DWORD fDsrSensitivity:1; /* DSR Sensitivity */

DWORD fTXContinueOnXoff: 1; /* Continue TX when Xoff sent */

DWORD fOutX: 1; /* Enable output X-ON/X-OFF */

DWORD fInX: 1; /* Enable input X-ON/X-OFF */

DWORD fErrorChar: 1; /* Enable Err Replacement */

DWORD fNull: 1; /* Enable Null stripping */

DWORD fRtsControl:2; /* Rts Flow control */

DWORD fAbortOnError:1; /* Abort all reads and writes on Error */

DWORD fDummy2:1; /* Reserved */

WORD wReserved; /* Not currently used */

WORD XonLim; /* Transmit X-ON threshold */

WORD XoffLim; /* Transmit X-OFF threshold */

BYTE ByteSize; /* Number of bits/byte, 4-8 */

BYTE Parity; /* 0-4=None,Odd,Even,Mark,Space */

BYTE StopBits; /* 0,1,2 = 1, 1.5, 2 */

char XonChar; /* Tx and Rx X-ON character */

char XoffChar; /* Tx and Rx X-OFF character */

char ErrorChar; /* Error replacement char */

char EofChar; /* End of Input character */

char EvtChar; /* Received Event character */

} DCB;

Return Value

The return value is TRUE if the function was successful. Otherwise, it is FALSE. Use the GetLastError function to obtain extended error information.

Comments

The BuildCommDCB function only fills the buffer. An application should use the SetCommState function to apply these settings to the port.

By default, BuildCommDCB specifies Xon/Xoff and hardware flow control as disabled. An application should set the appropriate members in the DCB data structure to enable flow control.

See Also

SetCommState