一、装置mscomm32.ocx控件
1、仿制mscomm32.ocx到windowssystem32下
2、注册
二、在c++builder下引进mscomm32.ocx
挑选菜单component->Import ActiveX Control,
挑选“Microsoft Comm Control 6.0(Version1.1)”,点击“install”
然后能够在ActiveX控件组看到一个像电话的控件。
三、树立使用工程
1、规划界面
引进了mscomm32控件,memo1控件,Button1,Button2,RadioButton1和RadioButton2
1) 其间memo1用于显现串口接纳内容
2)Button1用于操控串口的敞开和封闭,Button2用于停止使用程序
3)RadioButton1和RadioButton2用于挑选串口接纳方法(类型)
2、unit1.h内容,其间赤色为引进的全局变量
#include
#include
#include “MSCommLib_OCX.h”
#include
//—————————————————————————
class TForm1 : public TForm
{
__published: // IDE-managed Components
TMSComm *MSComm1;
TMemo *Memo1;
TButton *Button1;
TButton *Button2;
TGroupBox *GroupBox1;
TRadioButton *RadioButton1;
TRadioButton *RadioButton2;
void __fastcall Button1Click(TObject *Sender);
void __fastcall MSComm1Comm(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall FormCreate(TObject *Sender);
void __fastcall RadioButton1Click(TObject *Sender);
void __fastcall RadioButton2Click(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm1(TComponent* Owner);
int type;//0–字符串,1—二进制
};
//—————————————————————————
extern PACKAGE TForm1 *Form1;
//—————————————————————————
#endif