(27)串口通讯第一步就跌倒:createfile(66分)

  • 主题发起人 千中元
  • 开始时间

千中元

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure Tform1.comminitialize; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // 串 行 口 初 始 化<br>&nbsp;var<br>&nbsp;lpdcb:Tdcb;<br>&nbsp;Begin<br>&nbsp;hcom:=createfile('com2',generic_read or generic_write,0,nil,open_existing,<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;file_attribute_normal or file_flag_overlapped,0);// 打 开 串 &nbsp;行口<br>问题1:<br>&nbsp; 该把hcom声明成什么数据类型?<br>问题2:<br>&nbsp; 可以file_attribute_normal or file_flag_overlapped 组合?该组合什么意思?<br>&nbsp; 在api帮助里,对倒数第二个参数:“也可在Windows NT下组合使用下述常数标记: <br>SECURITY_ANONYMOUS, SECURITY_IDENTIFICATION, SECURITY_IMPERSONATION, SECURITY_DELEGATION, SECURITY_CONTEXT_TRACKING, SECURITY_EFFECTIVE_ONLY ”,<br>-------现在我用的是win2000 server版本,实现和同样的功能,该怎么改变?<br><br>
 
(1)WORD<br>(2)关键是FILE_FLAG_OVERLAPPED,看MSDN或Delphi里带的win32帮助<br>安全属性可以不管
 
改过以后,cant create output file. :(
 
改过什么?我试了一下你上面那句原始的话,串口被打开了。我也是win2000
 
你要保证<br>1)有COM2<br>2)COM2没有被鼠标、MODEM等设备使用。
 
hcom是THandle类型<br>file_attribute_normal 可以不要<br><br>
 
给你发了个例子
 
crane兄,<br>&nbsp; &nbsp; &nbsp;您要发到sheepishest@21cn.com我就再也找不到了,里面有2XXXX封新邮件:)
 
顶部