[ Pobierz całość w formacie PDF ]
.cbInQue > 0){if (Stat.cbInQue > Buf_Size)nNumberOfBytesToRead = Buf_Size;elsenNumberOfBytesToRead = Stat.cbInQue;ReadFile(hCommDev, &Buffer_I[0], nNumberOfBytesToRead,lpNumberOfBytesRead, NULL);}else*lpNumberOfBytesRead = 0;return TRUE;}//--------------------------------------------------------------------__fastcall TForm1::TForm1(TComponent* Owner): TForm(Owner){}//--------------------------------------------------------------------void __fastcall TForm1::CloseCommClick(TObject *Sender){switch(MessageBox(NULL, " Dzia³anie aplikacji zostanie"" zakoñczone.", "Uwaga!",MB_YESNOCANCEL | MB_ICONQUESTION)){case ID_YES :{SuspendThread((HANDLE)hThread_SR);Close_Comm(hCommDev);Application->Terminate();}case ID_CANCEL : Abort();}}//--------------------------------------------------------------------void __fastcall TForm1::FormCreate(TObject *Sender){OpenComm->Enabled = TRUE;UpDown1->Position = 1000;Edit1->Text = "1000";intVar = 0;}//--------------------------------------------------------------------void __fastcall TForm1::OpenCommClick(TObject *Sender){if (CheckBox1->Checked == TRUE) // wybór portulpFileName = "COM1";if (CheckBox2->Checked == TRUE)lpFileName = "COM2";hCommDev = CreateFile(lpFileName, GENERIC_READ | GENERIC_WRITE,0, NULL, OPEN_EXISTING, 0, NULL);if (hCommDev != INVALID_HANDLE_VALUE) // sprawdza, czy port jest// otwarty prawid³owo{SetupComm(hCommDev, cbInQueue, cbOutQueue);dcb.DCBlength = sizeof(dcb);GetCommState(hCommDev, &dcb);if (CheckBox3->Checked == TRUE) // wybór prêdkoœci transmisjidcb.BaudRate = CBR_300;if (CheckBox4->Checked == TRUE)dcb.BaudRate = CBR_1200;if (CheckBox5->Checked == TRUE)dcb.BaudRate = CBR_9600;dcb.Parity = ODDPARITY; // ustawienie parzystoœcidcb.StopBits = ONESTOPBIT; // bity stopudcb.ByteSize = 7; // bity danych//-przyk³adowe ustawienia znaczników steruj¹cych DCB-dcb.fParity = TRUE; // sprawdzanie parzystoœcidcb.fDtrControl = DTR_CONTROL_DISABLE;dcb.fRtsControl = RTS_CONTROL_DISABLE;dcb.fOutxCtsFlow = FALSE;dcb.fOutxDsrFlow = FALSE;dcb.fDsrSensitivity = FALSE;dcb.fAbortOnError = FALSE;dcb.fOutX = FALSE;dcb.fInX = FALSE;dcb.fErrorChar = FALSE;dcb.fNull = FALSE;SetCommState(hCommDev, &dcb);GetCommMask(hCommDev, &fdwEvtMask);SetCommMask(hCommDev, EV_TXEMPTY);}else{switch ((int)hCommDev){case IE_BADID:MessageBox(NULL, "Niew³aœciwa nazwa portu lub port jest"" aktywny
[ Pobierz całość w formacie PDF ]