procedure TForm1.OpenPortClick(Sender: TObject); var dcb:DCB;//报错:[Error] main_unit.pas(49): Constant or type identifier expected hCom:integer; fSuccess:boolean; Comstring:string; begin Comstring:='COM1'; try hCom:=CreateFile(Pchar(ComString), GENERIC_READ or GENERIC_WRITE, 0, Nil, OPEN_EXISTING, 0, Null); if hCom = INVALID_HANDLE_VALUE then //警告:[Warning] main_unit.pas(64): Comparison always evaluates to False begin Statusbar1.simpletext:='打开串口失败'; exit; end else Statusbar1.simpletext:='打开串口成功'; except application.MessageBox('程序发生异常','提示',mb_ok); end; end;是什么原因?
NIL是空指针型
2。直接引用相应的dcu即可
3.相当于C中的Cstring
uses winbase
然后copy to delphi/lib下就行
但不知道是windows单元
:)
这么说的用意是以后若出现相同问题都可照
此办理
var
dcb:DCB;//报错:[Error] main_unit.pas(49): Constant or type identifier expected
hCom:integer;
fSuccess:boolean;
Comstring:string;
begin Comstring:='COM1';
try
hCom:=CreateFile(Pchar(ComString),
GENERIC_READ or GENERIC_WRITE,
0,
Nil,
OPEN_EXISTING,
0,
Null);
if hCom = INVALID_HANDLE_VALUE then //警告:[Warning] main_unit.pas(64): Comparison always evaluates to False
begin
Statusbar1.simpletext:='打开串口失败';
exit;
end
else
Statusbar1.simpletext:='打开串口成功';
except
application.MessageBox('程序发生异常','提示',mb_ok);
end;
end;是什么原因?