GetCommState

  BOOL GetCommState(hCommDev, lpdcb)    
  HANDLE hCommDev; /* identifies the comm device */
  LPDCB lpdcb; /* address of structure for dcb */

The GetCommState function retrieves the device control block for the specified device.

Parameters

hCommDev

Identifies the device to be examined. The CreateFile function returns this value.

lpdcb

Points to the DCB structure that is to receive the current device control block.

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, or FALSE if an error occurred. Use the GetLastError function to obtain extended error information.

See Also

SetCommState