Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
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 CreateFilefunction.

lpDCB

[in] Long pointer to a DCBstructure containing the configuration information for the specified communications device.

Return Value

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

Remarks

The SetCommStatefunction uses a DCBstructure to specify the desired configuration. The GetCommStatefunction returns the current configuration.

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

The SetCommStatefunction fails if the XonCharmember of the DCBstructure is equal to the XoffCharmember.

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