MFC 封装C++类为dll

1.创建MFC dll工程,选择创建MFC扩展DLL

2.在.h中定义类

//.h文件
#include "CVRxVbm.h"
#include 
#pragma comment(lib,"VRxVbm.lib")
#pragma comment(lib,"QMailBox.lib")
class __declspec(dllexport) CVMSStream
{
public:
	int VMS_Init(int nPort);
	bool VMS_RecvData();
	bool VMS_PlayReturn();
	LPVOID VMS_PlayGetFrame(unsigned int *nBufferLen);
	void VMS_Stop();
	
private:
	CVRxVbm*      m_pcRxVbm;
	SOCKET        m_socket;
	char*         m_pcBuf;       //GetEmpty和PutPacketBuffer   
	char*         m_pRecv;        //recvfrom
	SOCKADDR_IN   m_addrSvr;
	int           m_from_len;

private:
	int CreateSocket(int nPort);
	char* AutoGetIP();
};
//.cpp 实现该类即可生成.dll 和.lib

参考资料:http://www.tekuba.net/program/209/


你可能感兴趣的:(开发经验,C++/C)