| 发表于:2007-06-04 09:04:56 楼主 |
我用dll导出一个类: carrayserial.h #ifdef dll_file class _declspec(dllexport) carrayserial //导出类carrayserial #else class _declspec(dllimport) carrayserial //导入类carrayserial #endif { public: bool initializedevice( cwnd* pportowner, uint portnr = 1, uint baud = 9600, char parity = 'n ', uint databits = 8, uint stopsbits = 2 ); } cserialarray.cpp bool carrayserial::initializedevice( cwnd* pportowner, // the owner (cwnd) of the port (receives message) uint portnr, // portnumber (1..4) uint baud, // baudrate char parity, // parity uint databits, // databits uint stopsbits // stopbits ) { hwnd htest = *pportowner; cstring strtemp; strtemp.format( "%d ", htest ); afxmessagebox( strtemp ); return true; } exe文件中引用: void cserialmfcdemodlg::onconnect() { // todo: add your control notification handler code here hwnd htest = *this; cstring strtemp2; strtemp2.format( "%d ", htest ); afxmessagebox( strtemp2 ); m_serialdevice.initializedevice( this, m_unport, m_unbaudrate, *( m_sparity.c_str() ), m_undatabit ); } 结果dll中弹出的窗口指针和exe弹出的窗口指针值不一样,不知是什么原因,改如何解决,谢谢!! |
|
|
|
|