⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delphi编程 --- 在delphi7中利用mscomm控件编程.htm

📁 串口通讯关于磁卡读写相关文章 资料串口控件的介绍和使用
💻 HTM
📖 第 1 页 / 共 2 页
字号:
      //清空发送缓冲区<BR>&nbsp; 
      mscomm1.PortOpen:=true;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      //打开端口<BR>&nbsp; MSComm1.RThreshold := 
      16;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//设置接收多少字节开产生oncomm事件<BR>&nbsp; 
      senddata[1]:=chr($06);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      //要发送的数据<BR>&nbsp; senddata[2]:=chr($03);<BR>&nbsp; 
      senddata[3]:=chr($00);<BR>&nbsp; senddata[4]:=chr($03);<BR>&nbsp; 
      senddata[5]:=chr($10);<BR>&nbsp; sendstr:='';<BR>&nbsp; for i:=1 to 5 
      do<BR>&nbsp; sendstr:=sendstr + senddata[i];<BR>&nbsp; 
      mscomm1.output:=sendstr;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      //发送数据<BR>&nbsp; i:=0;<BR>&nbsp; bzw:=false;<BR><BR>&nbsp; 
      repeat<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sleep(10);<BR>&nbsp;&nbsp;&nbsp; 
      Application.ProcessMessages;<BR>&nbsp;&nbsp;&nbsp; i := i + 
      1;<BR>&nbsp;&nbsp;&nbsp; If i &gt; 30000 
      Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      begin<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      showmessage('发送超时!');<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end;<BR>&nbsp; Until bzw = 
      true;<BR>&nbsp; redata:=mscomm1.Input;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      接收数据<BR>&nbsp; restr:='';<BR>&nbsp; for i:=0 to 
      vararrayhighbound(redata,1) do<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      restr:=restr + inttohex(redata[i],2)+' ';<BR>&nbsp; 
      mscomm1.PortOpen:=false;<BR>&nbsp; 
      flatmemo1.Text:=restr;<BR>end;<BR>//oncomm事件<BR>procedure 
      TForm1.MSComm1Comm(Sender: TObject);<BR>begin<BR>&nbsp; case 
      mscomm1.CommEvent of<BR>&nbsp;&nbsp;&nbsp; comEvReceive: bzw := 
      true;<BR>&nbsp; end;<BR>end; 
      <P>最后,记事发布软件时要带上Mscomm32.ocx文件。</P>
      <DIV style="TEXT-ALIGN: right; WIDTH: 100%"><A 
      href="http://www.9seek.com/news/show.aspx?id=566&amp;cid=11" target=_blank 
      title="Powered by DvNews"><FONT color=#333333 face=Tahoma,Arial 
      style="BACKGROUND: #ffffff; FONT-SIZE: 11px; TEXT-DECORATION: none">DvNews</FONT></A></DIV></SPAN><BR><BR>
      <TABLE cellPadding=0 cellSpacing=0 width="97%">
        <TBODY>
        <TR>
          <TD align=right>
            <TABLE>
              <TBODY>
              <TR>
                <TD>来源:<SPAN id=SourceLabel></SPAN><BR>阅读:<SPAN 
                  id=HitsLabel>1711</SPAN> 次<BR>日期:<SPAN 
                  id=TimeLabel>2005-3-16</SPAN><BR>录入:<SPAN 
                  id=MemberNameLabel><A 
                  href="http://61.130.50.195/memberProfile.aspx?id=2" 
                  target=_blank>cwj</A></SPAN><BR><BR></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD align=right>【 <A href="http://61.130.50.195/remark.aspx?ID=347" 
            target=_blank>评论</A> 】 【 <A 
            href="http://61.130.50.195/mail.aspx?ID=347" target=_blank>推荐</A> 】 
            【 <A href="javascript:doPrint()">打印</A> 】 【 字体:<A 
            href="javascript:ContentSize(16)">大</A> <A 
            href="javascript:ContentSize(14)">中</A> <A 
            href="javascript:ContentSize(12)">小</A> 】 </TD></TR></TBODY></TABLE>
      <TABLE align=center width="97%">
        <TBODY>
        <TR>
          <TD>上一篇:<A 
            href="http://61.130.50.195/show.aspx?id=344&amp;cid=23">Delphi 
            中串口通讯的实现</A><BR>下一篇:<A 
            href="http://61.130.50.195/show.aspx?id=376&amp;cid=23">ZY_602磁卡读写器测试程序</A> 
          </TD></TR></TBODY></TABLE></TD></TR>
  <TBODY id=printHide name="printHide">
  <TR>
    <TD class=summary-title>&nbsp; &gt;&gt; 相关新闻 &nbsp; &nbsp; &nbsp; </TD></TR>
  <TR class=tdbg vAlign=top>
    <TD 
    style="PADDING-BOTTOM: 5px; PADDING-LEFT: 2px; PADDING-RIGHT: 2px; PADDING-TOP: 5px">&nbsp; 
    </TD></TR>
  <TR>
    <TD align=middle class=summary-title>发表评论 </TD>
  <TR>
    <FORM action=remark.aspx?id=347 method=post name=remarkForm 
    onsubmit="return checkRemark();">
    <TD class=tdbg>
      <TABLE border=0 cellPadding=5 cellSpacing=0 width="100%">
        <TBODY>
        <TR>
          <TD>
            <SCRIPT>
			function checkRemark()
			{
			var form=document.all.remarkForm;
			if (form.body.value=="")
			{	alert("请填写评论内容");
				form.body.focus();
				return false;
			}
			if (form.username.value=="")
			{	alert("请填写姓名");
				form.username.focus();
				return false;
			}
			if (form.body.value.length>200)
			{	alert("评论内容不可以超过200字");
				form.body.focus();
				return false;
			}
			if (form.username.value.length>10)
			{	alert("姓名不可以超过10个字");
				form.username.focus();
				return false;
			}
			form.submit.disabled=true;
			return true;
			}
			function showLen(obj)
			{
				document.all.bodyLen.innerText=obj.value.length;
			}
			</SCRIPT>
            <INPUT CHECKED name=face type=radio value=1><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face1.gif"> <INPUT 
            name=face type=radio value=2><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face2.gif"> <INPUT 
            name=face type=radio value=3><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face3.gif"> <INPUT 
            name=face type=radio value=4><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face4.gif"> <INPUT 
            name=face type=radio value=5><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face5.gif"> <INPUT 
            name=face type=radio value=6><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face6.gif"> <INPUT 
            name=face type=radio value=7><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face7.gif"> <INPUT 
            name=face type=radio value=8><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face8.gif"> <INPUT 
            name=face type=radio value=9><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face9.gif"><BR><INPUT 
            name=face type=radio value=10><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face10.gif"> <INPUT 
            name=face type=radio value=11><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face11.gif"> <INPUT 
            name=face type=radio value=12><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face12.gif"> <INPUT 
            name=face type=radio value=13><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face13.gif"> <INPUT 
            name=face type=radio value=14><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face14.gif"> <INPUT 
            name=face type=radio value=15><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face15.gif"> <INPUT 
            name=face type=radio value=16><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face16.gif"> <INPUT 
            name=face type=radio value=17><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face17.gif"> <INPUT 
            name=face type=radio value=18><IMG 
            src="Delphi编程 --- 在delphi7中利用mscomm控件编程.files/face18.gif"><BR>点评: <TEXTAREA cols=40 name=body onkeydown=showLen(this) onkeyup=showLen(this) rows=4></TEXTAREA> 
            字数<SPAN id=bodyLen>0</SPAN> <BR>姓名: <INPUT maxLength=15 
            name=username size=10> <INPUT name=submit type=submit value=" 发 表 "> 
            <BR><BR><INPUT id=clientDate name=clientDate type=hidden>
            <SCRIPT language=javascript> d=new Date();document.all.clientDate.value=d.getYear()+","+d.getMonth()+","+d.getDate()+","+ d.getHours() +","+ d.getMinutes() +","+ d.getSeconds();</SCRIPT>
             </TD>
          <TD width=350>
            <UL 
              style="LINE-HEIGHT: 150%; LIST-STYLE: square; MARGIN-LEFT: 1em"><LI>尊重网上道德,遵守中华人民共和国的各项有关法律法规 

              <LI>承担一切因您的行为而直接或间接导致的民事或刑事法律责任 
              <LI>本站管理人员有权保留或删除其管辖留言中的任意内容 
              <LI>本站有权在网站内转载或引用您的评论 
              <LI>参与本评论即表明您已经阅读并接受上述条款 
  </LI></UL></TD></TR></TBODY></TABLE></TD></FORM></TR></TBODY></TABLE></DIV>
<TABLE align=center cellPadding=0 cellSpacing=0 class=twidth>
  <TBODY>
  <TR>
    <TD height=20></TD></TR>
  <TR>
    <TD class=footline></TD></TR>
  <TR align=middle height=60 style="LINE-HEIGHT: 130%">
    <TD>网站简介 - 广告服务 - 网站地图 - 帮助信息 - 联系方式<BR><A 
      href="http://www.miibeian.gov.cn/" 
      target=_blank>浙ICP备05037601号</A><BR>Copyright &copy; Delphi书屋 Powered by <A 
      href="http://www.9seek.com/news/show.aspx?id=566&amp;cid=11" target=_blank 
      title="-----------------------------------------    << &#13;&#10; 动网新闻.Net(Asp.net + C#)&#13;&#10;---------------------&#13;&#10; Version: 3.0 free version &#13;&#10; For personal and non-commercial use! &#13;&#10;--------------------- &#13;&#10;-----------------------------------------    <<">DvNews 
      3.0</A> </TD></TR></TBODY></TABLE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -