1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
theApp->hPort = CreateFile (lpszPortName, // Pointer to the name of the port
GENERIC_READ | GENERIC_WRITE,
// Access (read-write) mode
0, // Share mode
NULL, // Pointer to the security attribute
OPEN_EXISTING,// How to open the serial port
0, // Port attributes
NULL); // Handle to port with attribute
// to copy
// If it fails to open the port, return FALSE.
if ( theApp->hPort == INVALID_HANDLE_VALUE )
{
dwError = GetLastError ();
return FALSE;
}
PortDCB.DCBlength = sizeof (DCB);
// Get the default port setting information.
int returned = GetCommState (theApp->hPort, &PortDCB); |
Partager