I have code like this (it's declaration of interface functions which are implemented in DLL file - it's from book - Course PTR 3D Game Engine Programming):
extern "C"
{
HRESULT CreateRenderDevice(HINSTANCE hDLL, ZFXRenderDevice **pInterface);
typedef HRESULT (*CREATERENDERDEVICE)
(HINSTANCE hDLL, ZFXRenderDevice **pInterface);
HRESULT ReleaseRenderDevice(ZFXRenderDevice **pInterface);
typedef HRESULT(*RELEASERENDERDEVICE)
(ZFXRenderDevice **pInterface);
}
and it's used liked this
CREATERENDERDEVICE _CreateRenderDevice = 0;
HRESULT hr; // pointer to DLL function ‘CreateRenderDevice’
_CreateRenderDevice = (CREATERENDERDEVICE)
GetProcAddress(m_hDLL,“CreateRenderDevice”);
if ( !_CreateRenderDevice )
return E_FAIL; // call DLL function to create the device
hr = _CreateRenderDevice(m_hDLL, &m_pDevice);
I understand taht it's extracting function from DLL, but can someone explain me this part of the code? What construction is it (macro?) and how dos it works?
typedef HRESULT (*CREATERENDERDEVICE)
(HINSTANCE hDLL, ZFXRenderDevice **pInterface);
and also
typedef HRESULT(*RELEASERENDERDEVICE)
(ZFXRenderDevice **pInterface);
and usage of it
_CreateRenderDevice = (CREATERENDERDEVICE)
GetProcAddress(m_hDLL,“CreateRenderDevice”);