D
dyfh
Unregistered / Unconfirmed
GUEST, unregistred user!
刚才的程序不清晰,贴一个网上朋友的代码,他和我有同样的问题<br><br>if hCom = INVALID_HANDLE_VALUE then <br>这句为什么被警告//警告:[Warning] main_unit.pas(64): Comparison always evaluates to False<br><br>procedure TForm1.OpenPortClick(Sender: TObject);<br>var<br> hCom:integer;<br> fSuccess:boolean;<br> Comstring:string;<br>begin<br><br> Comstring:='COM1';<br> try<br> hCom:=CreateFile(Pchar(ComString),<br> GENERIC_READ or GENERIC_WRITE,<br> 0,<br> Nil,<br> OPEN_EXISTING,<br> 0,<br> Null);<br> if hCom = INVALID_HANDLE_VALUE then //警告:[Warning] main_unit.pas(64): Comparison always evaluates to False<br> begin<br> Statusbar1.simpletext:='打开串口失败';<br> exit;<br> end<br> else<br> Statusbar1.simpletext:='打开串口成功';<br> except<br> application.MessageBox('程序发生异常','提示',mb_ok);<br> end;<br>end;