UnitComm.h
上传用户:gyjjlc
上传日期:2013-03-29
资源大小:2124k
文件大小:1k
源码类别:

多显示器编程

开发平台:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #ifndef UnitCommH
  3. #define UnitCommH
  4. #define BLOCK_LENGTH 1024
  5. #include "UnitMain.h"
  6. class TCommunication:public TObject
  7. {
  8. public:
  9.     HANDLE hCom;
  10.     __fastcall TCommunication();
  11.     virtual __fastcall ~TCommunication();
  12.     bool __fastcall ComInitialization(AnsiString DevicePort,
  13.         int BaudRate,int ByteSize, int Parity, int StopBits);
  14.     char * __fastcall ReceiveProcess();
  15.     BOOL  __fastcall WriteCommBlock(LPSTR lpBlock,DWORD nMaxLength);
  16. private:
  17.     //接收缓冲区
  18.     char Buffer[BLOCK_LENGTH+1];
  19.     //接收缓冲区计数器,加1计数器
  20.     DWORD BufferOffset;
  21.     //分别为读、写重叠数据结构
  22.     OVERLAPPED osRead,osWrite;
  23.     DWORD  __fastcall ReadCommBlock(LPSTR lpBlock,DWORD nMaxLength);
  24. };
  25. //---------------------------------------------------------------------------
  26. #endif