通信编程问题,请各位高手帮帮忙。
gxlzx 2000-07-18 05:46:00 下面的程序在Delphi3中编译通过,在Delphi4中编译时出错:[Error] Modenf.pas(47): Types of actual and formal var parameters must be identical
代码如下(一个拔号程序):
unit Modenf;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
const
comPort='COM2';
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
hComm:THandle;
s:string;
i:longint;
begin
s:=' ';
if InputQuery('电话号码','请输入一个电话号码:',s) then
begin
s:='atdt'+s+#13;
hComm:=CreateFile(comPort,GENERIC_WRITE,0,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if hComm=INVALID_HANDLE_VALUE then
begin
ShowMessage('无法打开'+comPort);
Exit;
end;
if not WriteFile(hComm,PChar(s)^,Length(s),i,nil)then
ShowMessage('无法写入'+comPort);
CloseHandle(hComm);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hComm:THandle;
s:string;
i:Longint;
begin
s:='ath';
hComm:=CreateFile(comPort,GENERIC_WRITE,0,nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
if hComm=INVALID_HANDLE_VALUE then
begin
ShowMessage('无法打开'+comPort);
exit;
end;
if not WriteFile(hComm,PChar(s)^,Length(s),i,nil)then
ShowMessage('无法写入'+comPort);
CloseHandle(hComm);
end;
end.
请问是什么原因???