Mscomm is a strong control of Microsoft, which is powerful, simple, today we don't want, we can also use it in Delphi. These codes are for transmission and reception of 16-based processing.
Var Senddata: array [1..10] of char; redata: arch of variant; sendstr: string; rest; string; i: longint; begin mscomm1.commport: = 1; // Specify port mscomm1.settings: = '9600 , N, 8, 1 '; // Other parameters mscomm1.inbuffersize: = 1024; // Receive buffer MScomm1.outBuffersize: = 1024; // Send buffer MScomm1.inputMode: = cominputModeBinary; // Receive mode MScomm1.inputlen : = 0; // Read all data MScomm1.sthreshold: = 0; // Send all data mscomm1.inbuffercount: = 0; // Clear read buffer MScomm1.outbuffercount: = 0; // Clear transmission buffer District mscomm1.portopen: = true; // Open port mscomm1.rthreshold: = 16; // Set how many bytes of receiving ONCOMM event Senddata [1]: = CHR ($ 06); // To send data Senddata [2 ]: = CHR ($ 03); Senddata [3]: = CHR ($ 00); Senddata [4]: = CHR ($ 03); Senddata [5]: = CHR ($ 10); sendstr: = '; for i: = 1 to 5 do sendstr: = sendStr sendData [I]; mscomm1.output: = sendStr; // Send data i: = 0; bzw: = false; Repeat SLE EP (10); Application.ProcessMessages; i: = i 1; if i> 30000 Then Begin ShowMessage ('Send Timeout!'); Break; End; Until Bzw = true; redata: = mscomm1.input; Receive Data Restri : = '; For i: = 0 to VararrayHighBound (Redata, 1) Do Restr: = restr INTTOHEX (Redata [i], 2) ' '; mscomm1.Portopen: = false; flatmemo1.text: = restr; End; // oncomm event procedure tform1.mscomm1comm (sender: TOBJECT); Begin Case Mscomm1.commmevent of comevrece: bzw: = true; end; end; Finally, the memory will bring MSComm32.ocx files when the memory is released.