serial ports handling


[ Related Articles and Replies ] [ Post Followup ] [ DelphiLand Discussion Forum ]

Posted by Laetitia on January 03, 2003 at 16:38:26:

Hi !

I have been trying to send to and receive strings from my serial port using a demo written by Peter Johnson and Delphi 6.0. Here are a few important statements of it:

var
 DeviceName: Array[0..80] of Char; 
 ComFile: THandle;
 s: string;
 BytesWritten, BytesRead: Integer;
StrPCopy(DeviceName, 'COM1:');
ComFile := CreateFile(DeviceName, GENERIC_READ or GENERIC_WRITE, 
  0, Nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
s:='The string I want to send' + #13 + #10;
if not WriteFile (ComFile, s[1], Length(s), BytesWritten, Nil) then
 { Raise an exception }

When I try to compile the code, this last statement makes Delphi issue the following error message:

[Error] Unit1.pas(95): Types of actual and formal var parameters must be identical

Can anyone give me a tip on this problem ?

Many thanks

Laetitia


Related Articles and Replies:


[ Related Articles and Replies ] [ Post Followup ] [ DelphiLand Discussion Forum ]