361 lines
9.6 KiB
C
361 lines
9.6 KiB
C
|
|
#ifndef MODULE_HEAD_FILE
|
|||
|
|
#define MODULE_HEAD_FILE
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//ģ<><C4A3><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
|
|||
|
|
#define VER_IUnknownEx INTERFACE_VERSION(1,1)
|
|||
|
|
static const GUID IID_IUnknownEx={0x5feec21e,0xdbf3,0x46f0,0x9f,0x57,0xd1,0xcd,0x71,0x1c,0x46,0xde};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
interface IUnknownEx
|
|||
|
|
{
|
|||
|
|
//<2F>ͷŶ<CDB7><C5B6><EFBFBD>
|
|||
|
|
virtual VOID Release()=NULL;
|
|||
|
|
//<2F>ӿڲ<D3BF>ѯ
|
|||
|
|
virtual VOID * QueryInterface(REFGUID Guid, DWORD dwQueryVer)=NULL;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F>汾<EFBFBD>Ƚ<EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><>Ʒ<EFBFBD>汾
|
|||
|
|
#define BULID_VER 0 //<2F><>Ȩ<EFBFBD>汾
|
|||
|
|
#define PRODUCT_VER 6 //<2F><>Ʒ<EFBFBD>汾
|
|||
|
|
|
|||
|
|
//<2F>ӿڰ汾
|
|||
|
|
#define INTERFACE_VERSION(cbMainVer,cbSubVer) \
|
|||
|
|
(DWORD)( \
|
|||
|
|
(((BYTE)(PRODUCT_VER))<<24)+ \
|
|||
|
|
(((BYTE)(cbMainVer))<<16)+ \
|
|||
|
|
((BYTE)(cbSubVer)<<8))+ \
|
|||
|
|
((BYTE)(BULID_VER))
|
|||
|
|
|
|||
|
|
//ģ<><C4A3><EFBFBD>汾
|
|||
|
|
#define PROCESS_VERSION(cbMainVer,cbSubVer,cbBuildVer) \
|
|||
|
|
(DWORD)( \
|
|||
|
|
(((BYTE)(PRODUCT_VER))<<24)+ \
|
|||
|
|
(((BYTE)(cbMainVer))<<16)+ \
|
|||
|
|
((BYTE)(cbSubVer)<<8)+ \
|
|||
|
|
(BYTE)(cbBuildVer))
|
|||
|
|
|
|||
|
|
//<2F><>Ʒ<EFBFBD>汾
|
|||
|
|
inline BYTE GetProductVer(DWORD dwVersion)
|
|||
|
|
{
|
|||
|
|
return ((BYTE *)&dwVersion)[3];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ҫ<EFBFBD>汾
|
|||
|
|
inline BYTE GetMainVer(DWORD dwVersion)
|
|||
|
|
{
|
|||
|
|
return ((BYTE *)&dwVersion)[2];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>Ҫ<EFBFBD>汾
|
|||
|
|
inline BYTE GetSubVer(DWORD dwVersion)
|
|||
|
|
{
|
|||
|
|
return ((BYTE *)&dwVersion)[1];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>汾
|
|||
|
|
inline BYTE GetBuildVer(DWORD dwVersion)
|
|||
|
|
{
|
|||
|
|
return ((BYTE *)&dwVersion)[0];
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>汾<EFBFBD>Ƚ<EFBFBD>
|
|||
|
|
inline bool InterfaceVersionCompare(DWORD dwQueryVer, DWORD dwInterfaceVer)
|
|||
|
|
{
|
|||
|
|
if (GetSubVer(dwQueryVer)>GetSubVer(dwInterfaceVer)) return false;
|
|||
|
|
if (GetMainVer(dwQueryVer)!=GetMainVer(dwInterfaceVer)) return false;
|
|||
|
|
if (GetBuildVer(dwQueryVer)!=GetBuildVer(dwInterfaceVer)) return false;
|
|||
|
|
if (GetProductVer(dwQueryVer)!=GetProductVer(dwInterfaceVer)) return false;
|
|||
|
|
return true;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F>ڲ<EFBFBD><DAB2>ӿڲ<D3BF>ѯ
|
|||
|
|
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
#define QUERYINTERFACE(Interface,Guid,dwQueryVer) \
|
|||
|
|
if ((Guid==IID_##Interface)&&(InterfaceVersionCompare(dwQueryVer,VER_##Interface))) \
|
|||
|
|
return static_cast<Interface *>(this);
|
|||
|
|
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
#define QUERYINTERFACE_IUNKNOWNEX(BaseInterface,Guid,dwQueryVer) \
|
|||
|
|
if ((Guid==IID_IUnknownEx)&&(InterfaceVersionCompare(dwQueryVer,VER_IUnknownEx))) \
|
|||
|
|
return static_cast<IUnknownEx *>(static_cast<BaseInterface *>(this));
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F>ⲿ<EFBFBD>ӿڲ<D3BF>ѯ
|
|||
|
|
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
#define QUERY_ME_INTERFACE(Interface) \
|
|||
|
|
((Interface *)QueryInterface(IID_##Interface,VER_##Interface))
|
|||
|
|
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
#define QUERY_OBJECT_INTERFACE(Object,Interface) \
|
|||
|
|
((Interface *)Object.QueryInterface(IID_##Interface,VER_##Interface))
|
|||
|
|
|
|||
|
|
//<2F><>ѯ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
#define QUERY_OBJECT_PTR_INTERFACE(pObject,Interface) \
|
|||
|
|
((pObject==NULL)?NULL:((Interface *)pObject->QueryInterface(IID_##Interface,VER_##Interface)))
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD>帨<EFBFBD><E5B8A8>ģ<EFBFBD><C4A3>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
typedef VOID * (ModuleCreateProc)(REFGUID Gudi, DWORD dwInterfaceVer);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
|||
|
|
template <typename IModeluInterface> class CTempldateHelper
|
|||
|
|
{
|
|||
|
|
//<2F>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
REFGUID m_Guid; //<2F>ӿڱ<D3BF>ʶ
|
|||
|
|
const DWORD m_dwVersion; //<2F>ӿڰ汾
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
CHAR m_szCreateProc[32]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
TCHAR m_szModuleDllName[MAX_PATH]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F>ں˱<DABA><CBB1><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
HINSTANCE m_hDllInstance; //DLL <20><><EFBFBD><EFBFBD>
|
|||
|
|
IModeluInterface * m_pIModeluInterface; //ģ<><C4A3><EFBFBD>ӿ<EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
TCHAR m_szDescribe[128]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CTempldateHelper(REFGUID Guid, DWORD dwVersion);
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
CTempldateHelper(REFGUID Guid, DWORD dwVersion, LPCTSTR pszModuleDll, LPCSTR pszCreateProc);
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
virtual ~CTempldateHelper();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
//<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CloseInstance();
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
bool CreateInstance();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
VOID SetModuleCreateInfo(LPCTSTR pszModuleDllName, LPCSTR pszCreateProc);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public:
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
inline LPCTSTR GetErrorDescribe() const;
|
|||
|
|
//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
inline IModeluInterface * operator->() const;
|
|||
|
|
//<2F><>ȡ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
inline IModeluInterface * GetInterface() const;
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
// CTempldateHelper<IModeluInterface> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
CTempldateHelper<IModeluInterface>::CTempldateHelper(REFGUID Guid, DWORD dwVersion) : m_dwVersion(dwVersion), m_Guid(Guid)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_szDescribe[0]=0;
|
|||
|
|
|
|||
|
|
//<2F>ں<EFBFBD><DABA><EFBFBD>Ϣ
|
|||
|
|
m_hDllInstance=NULL;
|
|||
|
|
m_pIModeluInterface=NULL;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ZeroMemory(m_szCreateProc,sizeof(m_szCreateProc));
|
|||
|
|
ZeroMemory(m_szModuleDllName,sizeof(m_szModuleDllName));
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>캯<EFBFBD><ECBAAF>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
CTempldateHelper<IModeluInterface>::CTempldateHelper(REFGUID Guid, DWORD dwVersion, LPCTSTR pszModuleDll, LPCSTR pszCreateProc) : m_dwVersion(dwVersion), m_Guid(Guid)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_szDescribe[0]=0;
|
|||
|
|
|
|||
|
|
//<2F>ں<EFBFBD><DABA><EFBFBD>Ϣ
|
|||
|
|
m_hDllInstance=NULL;
|
|||
|
|
m_pIModeluInterface=NULL;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
lstrcpynA(m_szCreateProc,pszCreateProc,CountArray(m_szCreateProc));
|
|||
|
|
lstrcpyn(m_szModuleDllName,pszModuleDll,CountArray(m_szModuleDllName));
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
CTempldateHelper<IModeluInterface>::~CTempldateHelper()
|
|||
|
|
{
|
|||
|
|
CloseInstance();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
bool CTempldateHelper<IModeluInterface>::CreateInstance()
|
|||
|
|
{
|
|||
|
|
//<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
CloseInstance();
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
//Ч<><D0A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
ASSERT(m_szCreateProc[0]!=0);
|
|||
|
|
ASSERT(m_szModuleDllName[0]!=0);
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3>
|
|||
|
|
m_hDllInstance=AfxLoadLibrary(m_szModuleDllName);
|
|||
|
|
if (m_hDllInstance==NULL)
|
|||
|
|
{
|
|||
|
|
DWORD dwError = GetLastError();
|
|||
|
|
_sntprintf_s(m_szDescribe,CountArray(m_szDescribe),TEXT("<EFBFBD><EFBFBD>%s<><73>ģ<EFBFBD><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>"),m_szModuleDllName);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//Ѱ<>Һ<EFBFBD><D2BA><EFBFBD>
|
|||
|
|
ModuleCreateProc * CreateProc=(ModuleCreateProc *)GetProcAddress(m_hDllInstance,m_szCreateProc);
|
|||
|
|
if (CreateProc==NULL)
|
|||
|
|
{
|
|||
|
|
_sntprintf_s(m_szDescribe, CountArray(m_szDescribe), TEXT("<EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<><73>"), m_szCreateProc);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
m_pIModeluInterface=(IModeluInterface *)CreateProc(m_Guid,m_dwVersion);
|
|||
|
|
if (m_pIModeluInterface==NULL)
|
|||
|
|
{
|
|||
|
|
_sntprintf_s(m_szDescribe, CountArray(m_szDescribe), TEXT("<EFBFBD><EFBFBD><EFBFBD>ú<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD>ʧ<EFBFBD><CAA7>"), m_szCreateProc);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (LPCTSTR pszError)
|
|||
|
|
{
|
|||
|
|
_sntprintf_s(m_szDescribe, CountArray(m_szDescribe), TEXT("<EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>"), pszError);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
catch (...)
|
|||
|
|
{
|
|||
|
|
_sntprintf_s(m_szDescribe, CountArray(m_szDescribe), TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%s<><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ֪<CEB4>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><CAA7>"), m_szCreateProc);
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
bool CTempldateHelper<IModeluInterface>::CloseInstance()
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD>ñ<EFBFBD><C3B1><EFBFBD>
|
|||
|
|
m_szDescribe[0]=0;
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD>ٶ<EFBFBD><D9B6><EFBFBD>
|
|||
|
|
if (m_pIModeluInterface!=NULL)
|
|||
|
|
{
|
|||
|
|
m_pIModeluInterface->Release();
|
|||
|
|
m_pIModeluInterface=NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F>ͷ<EFBFBD> DLL
|
|||
|
|
if (m_hDllInstance!=NULL)
|
|||
|
|
{
|
|||
|
|
AfxFreeLibrary(m_hDllInstance);
|
|||
|
|
m_hDllInstance=NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
VOID CTempldateHelper<IModeluInterface>::SetModuleCreateInfo(LPCTSTR pszModuleDllName, LPCSTR pszCreateProc)
|
|||
|
|
{
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|||
|
|
lstrcpynA(m_szCreateProc,pszCreateProc,CountArray(m_szCreateProc));
|
|||
|
|
lstrcpyn(m_szModuleDllName,pszModuleDllName,CountArray(m_szModuleDllName));
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
// CTempldateHelper<IModeluInterface> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
inline LPCTSTR CTempldateHelper<IModeluInterface>::GetErrorDescribe() const
|
|||
|
|
{
|
|||
|
|
return m_szDescribe;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//ָ<><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
inline IModeluInterface * CTempldateHelper<IModeluInterface>::operator->() const
|
|||
|
|
{
|
|||
|
|
return GetInterface();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><>ȡ<EFBFBD>ӿ<EFBFBD>
|
|||
|
|
template <typename IModeluInterface>
|
|||
|
|
inline IModeluInterface * CTempldateHelper<IModeluInterface>::GetInterface() const
|
|||
|
|
{
|
|||
|
|
return m_pIModeluInterface;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define DECLARE_CREATE_MODULE(OBJECT_NAME) \
|
|||
|
|
extern "C" __declspec(dllexport) VOID * Create##OBJECT_NAME(REFGUID Guid, DWORD dwInterfaceVer) \
|
|||
|
|
{ \
|
|||
|
|
C##OBJECT_NAME * p##OBJECT_NAME=NULL; \
|
|||
|
|
try \
|
|||
|
|
{ \
|
|||
|
|
p##OBJECT_NAME=new C##OBJECT_NAME(); \
|
|||
|
|
if (p##OBJECT_NAME==NULL) throw TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>"); \
|
|||
|
|
VOID * pObject=p##OBJECT_NAME->QueryInterface(Guid,dwInterfaceVer); \
|
|||
|
|
if (pObject==NULL) throw TEXT("<EFBFBD>ӿڲ<EFBFBD>ѯʧ<EFBFBD><EFBFBD>"); \
|
|||
|
|
return pObject; \
|
|||
|
|
} \
|
|||
|
|
catch (...) {} \
|
|||
|
|
SafeDelete(p##OBJECT_NAME); \
|
|||
|
|
return NULL; \
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define DECLARE_MODULE_DYNAMIC(OBJECT_NAME) \
|
|||
|
|
class C##OBJECT_NAME##Helper : public CTempldateHelper<I##OBJECT_NAME> \
|
|||
|
|
{ \
|
|||
|
|
public: \
|
|||
|
|
C##OBJECT_NAME##Helper() : CTempldateHelper<I##OBJECT_NAME>(IID_I##OBJECT_NAME,VER_I##OBJECT_NAME) { } \
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
#define DECLARE_MODULE_HELPER(OBJECT_NAME,MODULE_DLL_NAME,CREATE_FUNCTION_NAME) \
|
|||
|
|
class C##OBJECT_NAME##Helper : public CTempldateHelper<I##OBJECT_NAME> \
|
|||
|
|
{ \
|
|||
|
|
public: \
|
|||
|
|
C##OBJECT_NAME##Helper() : CTempldateHelper<I##OBJECT_NAME>(IID_I##OBJECT_NAME, \
|
|||
|
|
VER_I##OBJECT_NAME,MODULE_DLL_NAME,CREATE_FUNCTION_NAME) { } \
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|||
|
|
|
|||
|
|
#endif
|