DCB dcb; HANDLE hCom; char buf[1024]="atdp43973"; BOOL fSuccess; DWORD ByteCount; char *pcCommPort = "COM1"; hCom = CreateFile( pcCommPort,GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL); if (hCom == INVALID_HANDLE_VALUE) { // Handle the error. return; } // Build on the current configuration, and skip setting the size // of the input and output buffers with SetupComm. fSuccess = GetCommState(hCom, &dcb); if (!fSuccess) { // Handle the error. return; } // Fill in DCB: 57,600 bps, 8 data bits, no parity, and 1 stop bit. dcb.BaudRate = CBR_57600; // set the baud rate dcb.ByteSize = 8; // data size, xmit, and rcv dcb.Parity = NOPARITY; // no parity bit dcb.StopBits = ONESTOPBIT; // one stop bit fSuccess = SetCommState(hCom, &dcb); if (!fSuccess) { MessageBeep(1000); // Handle the error. return; } SetupComm(hCom,1024,1024); WriteFile(hCom,&buf,1024,&ByteCount,NULL); CloseHandle(hCom);