1:类构造私有化
2:不直接操作成员变量
3: static CGameUpdate* CreateGameUpdateInstance(); 创建类
#pragma once
class __declspec(dllexport) CGameUpdate
{
private:
CGameUpdate(void);
public:
~CGameUpdate(void);
static CGameUpdate* CreateGameUpdateInstance();
DWORD m_dwXXX;
BOOL SetVersion(DWORD dwVersion);
DWORD m_dwVersion;
DWORD GetVersion();
};
CGameUpdate* CGameUpdate::CreateGameUpdateInstance()
{
return new CGameUpdate();
}
; YeookDll.def : Declares the module parameters for the DLL.
LIBRARY
EXPORTS
; Explicit exports can go here
CreateGameUpdateInstance
#include "../YeookDll/GameUpdate.h"
#pragma comment(lib,"../bin/YeookDll.lib")
void CYeookMainDlg::OnBnClickedButton1()
{
// TODO: Add your control notification handler code here
CGameUpdate* pTheGameUpdate = CGameUpdate::CreateGameUpdateInstance();
DWORD dwRet = pTheGameUpdate->GetVersion();
CString strTemp;
strTemp.Format(_T("%d"), dwRet);
AfxMessageBox(strTemp);
}