当前位置: 代码迷 >> VC >> 哪位高手有Visual C++ 2005 关于SerialPort 串口通讯例子
  详细解决方案

哪位高手有Visual C++ 2005 关于SerialPort 串口通讯例子

热度:10234   发布时间:2013-02-25 00:00:00.0
谁有Visual C++ 2005 关于SerialPort 串口通讯例子
如题

------解决方案--------------------------------------------------------
转一段代码给你看看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Threading;

namespace TestSerialPort
{
public partial class frmTESTSerialPort : Form
{
public frmTESTSerialPort()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}

private Button button1;
private TextBox txtSend;
private TextBox txtReceive;
private Label label1;
private Label label2;

/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name= "disposing "> 如果应释放托管资源,为 true;否则为 false。 </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码

/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.txtSend = new System.Windows.Forms.TextBox();
this.txtReceive = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(440, 379);
this.button1.Name = "button1 ";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "发送 ";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtSend
//
this.txtSend.Location = new System.Drawing.Point(59, 12);
this.txtSend.Multiline = true;
this.txtSend.Name = "txtSend ";
this.txtSend.Size = new System.Drawing.Size(456, 164);
this.txtSend.TabIndex = 2;
//
// txtReceive
//
this.txtReceive.Location = new System.Drawing.Point(59, 200);
this.txtReceive.Multiline = true;
this.txtReceive.Name = "txtReceive ";
this.txtReceive.Size = new System.Drawing.Size(456, 164);
this.txtReceive.TabIndex = 2;
//
// label1
//
this.label1.Location = new System.Drawing.Point(13, 15);
this.label1.Name = "label1 ";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "发送 ";
//
// label2
//
  相关解决方案