做一个MFC常规dll,使用了serial类,其中有个函数是初始化串口的,为
BOOL CSerialPort::InitPort(CWnd* pPortOwner, // the owner (CWnd) of the port (receives message) UINT portnr,UINT baud,char parity,UINT databits,UINT stopbits,DWORD dwCommEvents,UINT writebuffersize)
在应用程序中可以这样使用m_Port.InitPort(this,1,19200,'E',8,1,m_dwCommEvents,512);
但是在MFC常规dll中的函数如
__declspec(dllexport) void Init(void)
{
theApp.m_Port.InitPort(this,1,19200,'E',8,1);
theApp.m_Port.StartMonitoring();
}
就不能使用,会说全局函数Init不能使用this指针,那我应该怎样使用呢?谢谢各位!
BOOL CSerialPort::InitPort(CWnd* pPortOwner, // the owner (CWnd) of the port (receives message) UINT portnr,UINT baud,char parity,UINT databits,UINT stopbits,DWORD dwCommEvents,UINT writebuffersize)
在应用程序中可以这样使用m_Port.InitPort(this,1,19200,'E',8,1,m_dwCommEvents,512);
但是在MFC常规dll中的函数如
__declspec(dllexport) void Init(void)
{
theApp.m_Port.InitPort(this,1,19200,'E',8,1);
theApp.m_Port.StartMonitoring();
}
就不能使用,会说全局函数Init不能使用this指针,那我应该怎样使用呢?谢谢各位!
{
theApp.m_Port.InitPort(this,1,19200,'E',8,1);
theApp.m_Port.StartMonitoring();
}theApp ???
It's existing as MFC regular DLL, thus you may need to use the method AfxGetApp()->m_Port.InitPort(...)
地址为http://community.csdn.net/Expert/topic/5024/5024472.xml?temp=.4544489