📄 dsa_tsjl06tasync.cpp
字号:
//---------------------------------------------------------------------------
#include <windows.h>
#pragma hdrstop
#include "dsa_TSJL06TAsync.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
TRs232Async::TRs232Async(bool debug)
{
PrintDebugInfo=debug;
PortOpened=false;
overlapRX.hEvent=INVALID_HANDLE_VALUE;
overlapTX.hEvent=INVALID_HANDLE_VALUE;
overlapWait.hEvent=INVALID_HANDLE_VALUE;
ThreadRun=false;
NotifyWindow=NULL;
ReceiverMessageId=WM_USER+741;
SenderMessageId=0;
}
//---------------------------------------------------------------------------
TRs232Async::~TRs232Async()
{
Close();
}
//---------------------------------------------------------------------------
void TRs232Async::PrintException(string Caller, string &Message)
{
if(PrintDebugInfo){
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
Message="GetLastError="+string((char *)lpMsgBuf)+Caller+": "+Message;
// Free the buffer.
LocalFree( lpMsgBuf );
MessageBox(NotifyWindow, Message.c_str(), "Exception Message", MB_OK|MB_ICONWARNING);
}
}
//---------------------------------------------------------------------------
string TRs232Async::EnumerateProvider(int ProvSubType)
{
switch(ProvSubType){
case PST_FAX: return "FAX device";
case PST_LAT: return "LAT protocol";
case PST_MODEM: return "Modem device";
case PST_NETWORK_BRIDGE: return "Unspecified network bridge";
case PST_PARALLELPORT: return "Parallel port";
case PST_RS232: return "RS-232 serial port";
case PST_RS422: return "RS-422 port";
case PST_RS423: return "RS-423 port";
case PST_RS449: return "RS-449 port";
case PST_SCANNER: return "Scanner device";
case PST_TCPIP_TELNET: return "TCP/IP Telnet
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -