Schreiben über Serielle Schnittstelle:
HANDLE hCom = CreateFile(„COM2“,GENERIC_WRITE, 0, /* comm devices must be opened w/exclusive-access */
NULL, /* no security attrs */
OPEN_EXISTING, /* comm devices must use OPEN_EXISTING */
0, /* not overlapped I/O */
NULL /* hTemplate must be NULL for comm devices */
);
if (hCom == INVALID_HANDLE_VALUE)
{
dwError = GetLastError(); /* handle error */
AfxMessageBox(„ERROR opening COM PORT“);
}/* * Omit the call to SetupComm to use the default queue sizes. * Get the current configuration. */
fSuccess = GetCommState(hCom, &dcb);
/* Fill in the DCB: baud=9600, 8 data bits, no parity, 1 stop bit. */
dcb.BaudRate = 9600;
dcb.ByteSize = 7;
dcb.fOutxDsrFlow = TRUE;
dcb.fOutxCtsFlow = TRUE;
dcb.fParity = TRUE;
dcb.Parity = ODDPARITY;
dcb.StopBits = ONESTOPBIT;
fSuccess = SetCommState(hCom, &dcb);
unsigned long aa;
char strg[]=„Das ist mein Teststring zum Senden“;
if(WriteFile (hCom,strg,sizeof(strg),&aa,0)==0)AfxMessageBox („ERROR writing to COM PORT“);
CloseHandle(hCom);