KsBuildCommDCB

The availability of this function depends on what the device supports.

Fills a specified DCB structure with values specified in a device-control string. The device-control string uses the syntax of the mode command.

Syntax

BOOL KsBuildCommDCB(
     LPCWSTR lpDef,
     LPDCB lpDCB
);

Parameters

lpDef: the device-control information. The function takes this string, parses it, and then sets appropriate values in the DCB structure pointed to by lpDCB.

The string must have the same form as the mode command's command-line arguments:

COMx[:][baud=b][parity=p][data=d][stop=s][to={on|off}][xon={on|off}][odsr={on|off}][octs={on|off}][dtr={on|off|hs}][rts={on|off|hs|tg}][idsr={on|off}]

The device name is optional, but it must specify a valid device if used.

For example, the following string specifies a baud rate of 1200, no parity, 8 data bits, and 1 stop bit:

baud=1200 parity=N data=8 stop=1

lpDCB: a pointer to a DCB structure that receives the information.

Return value

If the function succeeds, it returns TRUE, otherwise FALSE. To get extended error information, call GetLastError.

Remarks

The KsBuildCommDCB function adjusts only those members of the DCB structure that are specifically affected by the lpDef parameter, with the following exceptions:

The KsBuildCommDCB function only fills in the members of the DCB structure. To apply these settings to a serial port, use the KsSetCommState function.

There are older and newer forms of the mode syntax. The KsBuildCommDCB function supports both forms. However, you cannot mix the two forms together.

The newer form of the mode syntax lets you explicitly set the values of the flow control members of the DCB structure. If you use an older form of the mode syntax, the BuildCommDCB function sets the flow control members of the DCB structure, as follows:

Example

N/A

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header kscom.h kscom.h
Library KsApi_Rtss.lib ksapi.h

See also

KsSetCommState