SetCommState

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function configures a communications device according to specifications in a device-control block (DCB) structure.

The function reinitializes hardware and control settings, but does not empty output or input queues.

Syntax

BOOL SetCommState(
  HANDLE hFile,
  LPDCB lpDCB
); 

Parameters

  • hFile
    [in] Handle to the communications device returned by the CreateFile function.
  • lpDCB
    [in] Long pointer to a DCB structure containing the configuration information for the specified communications device.

Return Value

Nonzero indicates success. Zero indicates failure. To obtain extended error information, call the GetLastError function.

Remarks

The SetCommState function uses a DCB structure to specify the desired configuration. The GetCommState function returns the current configuration.

To set only a few members of the DCB structure, modify a DCB structure that has been filled in by a call to GetCommState. This ensures that other members of the DCB structure have appropriate values.

The SetCommState function fails if the XonChar member of the DCB structure is equal to the XoffChar member.

Requirements

Header winbase.h
Library Serdev.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

Serial Communications Functions
GetCommState
DCB

Other Resources

CreateFile