This function configures a communications device according to the specifications in a device-control block (a DCB structure). The function reinitializes all hardware and control settings, but it does not empty output or input queues.
At a Glance
Header file: | Winbase.h |
Windows CE versions: | 1.0 and later |
Syntax
BOOL SetCommState(HANDLE hFile, LPDCB lpDCB);
Parameters
hFile
[in] Handle to the communications device. The CreateFile function returns this handle.
lpDCB
[in] Long pointer to a DCB structure containing the configuration information for the specified communications device.
Return Values
Nonzero indicates success. Zero indicates failure. To get extended error information, call GetLastError.
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, you should modify a DCB structure that has been filled in by a call to GetCommState. This ensures that the 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.
See Also