刚开始用C++ Builder 现在遇到一个关于串口通讯的问题。我用MSCOMM控件写一个读串口数据的程序,代码如下:
/---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "MSCommLib_OCX"
#pragma resource "*.dfm"
TForm1 *Form1;
AnsiString S;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
MSComm1->PortOpen=true;
S=WideString(MSComm1->Input);
Label1->Caption=S;
}
//---------------------------------------------------------------------
希望大家帮我看看这个程序错在什么地方?