资源简介
C++写的COM DLL文件,可用VB,VC引用.
代码片段和文件信息
#include
#include
#include
#define FC_DTRDSR 0x01
#define FC_RTSCTS 0x02
#define FC_XONXOFF 0x04
#define ASCII_BEL 0x07
#define ASCII_BS 0x08
#define ASCII_LF 0x0A
#define ASCII_CR 0x0D
#define ASCII_XON 0x11
#define ASCII_XOFF 0x13
//*************************** Open COM & Initial COM *****************************
HANDLE _stdcall OpenCom( DWORD nPort DWORD nBaud )
{
HANDLE m_hIDComDev;
OVERLAPPED m_OverlappedReadm_OverlappedWrite;
char szPort[15];
char szComParams[50];
DCB dcb;
m_hIDComDev = NULL;
if(nPort>8)
return NULL;
wsprintf(szPort “COM%d“ nPort);
m_hIDComDev = CreateFile( szPort
GENERIC_READ | GENERIC_WRITE
0
NULL
OPEN_EXISTING
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED
NULL );
if( m_hIDComDev == NULL )
return NULL;
memset(&m_OverlappedRead 0 sizeof( OVERLAPPED) );
memset(&m_OverlappedWrite 0 sizeof(OVERLAPPED) );
COMMTIMEOUTS CommTimeOuts;
CommTimeOuts.ReadIntervalTimeout = 0xFFFFFFFF;
CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
CommTimeOuts.ReadTotalTimeoutConstant = 0;
CommTimeOuts.WriteTotalTimeoutMultiplier = 0;
CommTimeOuts.WriteTotalTimeoutConstant = 5000;
SetCommTimeouts( m_hIDComDev &CommTimeOuts );
wsprintf( szComParams “COM%d:%dn81“ nPort nBaud );
m_OverlappedRead.hEvent = CreateEvent( NULL TRUE FALSE NULL );
m_OverlappedWrite.hEvent = CreateEvent( NULL TRUE FALSE NULL );
dcb.DCBlength = sizeof( DCB );
GetCommState( m_hIDComDev &dcb );
dcb.BaudRate = nBaud;
dcb.ByteSize = 8;
unsigned char ucSet;
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_DTRDSR ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_RTSCTS ) != 0 );
ucSet = (unsigned char) ( ( FC_RTSCTS & FC_XONXOFF ) != 0 );
if( !SetCommState( m_hIDComDev &dcb ) ||
!SetupComm( m_hIDComDev 10000 10000 ) ||
m_OverlappedRead.hEvent == NULL ||
m_OverlappedWrite.hEvent == NULL )
{
DWORD dwError = GetLastError();
if( m_OverlappedRead.hEvent != NULL )
CloseHandle( m_OverlappedRead.hEvent );
if( m_OverlappedWrite.hEvent != NULL )
CloseHandle( m_OverlappedWrite.hEvent );
CloseHandle( m_hIDComDev );
return NULL;
}
return m_hIDComDev;
}
//*****
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 208970 2008-10-24 10:11 COM\Debug\SerialCom.dll
文件 1401 2008-10-24 09:22 COM\Debug\SerialCom.exp
文件 286352 2008-10-24 10:11 COM\Debug\SerialCom.ilk
文件 3450 2008-10-24 09:22 COM\Debug\SerialCom.lib
文件 26285 2008-10-24 10:11 COM\Debug\SerialCom.obj
文件 3569976 2008-10-23 08:43 COM\Debug\SerialCom.pch
文件 648192 2008-10-24 10:11 COM\Debug\SerialCom.pdb
文件 148480 2009-03-17 10:28 COM\Debug\vc60.idb
文件 77824 2008-10-24 10:11 COM\Debug\vc60.pdb
文件 12867 2008-10-24 10:11 COM\SerialCom.cpp
文件 131 2008-10-23 16:51 COM\SerialCom.def
文件 4155 2008-10-22 11:16 COM\SerialCom.dsp
文件 543 2008-10-22 09:58 COM\SerialCom.dsw
文件 1173 2008-10-22 11:13 COM\SerialCom.h
文件 50176 2009-03-17 10:29 COM\SerialCom.ncb
文件 53760 2009-03-17 10:29 COM\SerialCom.opt
文件 252 2008-10-29 17:31 COM\SerialCom.plg
目录 0 2008-10-29 17:31 COM\Debug
目录 0 2009-03-17 10:29 COM
----------- --------- ---------- ----- ----
5093987 19
相关资源
- DICOM图像c++打开程序
- MX Component v3 编程手册 中文版
- vc++使用大漠使用和dll头文件等.rar
- MX Component Ver4 编程手册
- SQL server compact 3.5
- C++调用C#dll代码
- C#调用C++的dll,回调函数,string和in
- Borland C++ 5.5 编译器
- C++dll生成给C#调用
- matcom4.5
- Wava 6000 (内有comp86汇编编译器,com
- (VC)MFC Skinsharp换肤套装(lib+dll+h+编
- MFC些的串口调试助手源码
- DLL加密授权工具MaxtoCode破解版3.5
- wavelet的dll封装与c++调用
- 《Computer Systems--A Programmer‘s Perspect
- vs使用纯c++编写的com组件
- 可以将DLL文件转换成源码
- ComplexMatrixMathLab(C++复数矩阵数学库,
- msvcr120.dll64位与vcredist_x64.exe打包,解
- C/C++:Windows编程—调用DLL程序的2种方
- iocomp工业控件说明书
- VC6.0 多国语言切换(DLL版本,包含D
- libstdc++-6.dll
- 共享mfc的dll
- VB通过ActiveX的DLL与S7-1200/1500以太网通
- VB皮肤控件 SkinSharp (SkinH_VB6.dll 破解
- VS2019c++装换为动态链接库DLL.doc
- c++ 17 the complete guide
- DLL反编译C++工具
评论
共有 条评论