Get Exported Function Pointer
4.2 Get the DLL Export Function
4.2 Get the DLL exported function
The code is available in function _loadDLL from LZNV_DLL_Tester.cpp
#include <LZNV_Defines.h> // load header file from predefined include paths
#define IMPORT_DLL_PROCEDURE_(_function_type, _mp_function_variable, _literal_function_name_, _text_loaded_) \
_mp_function_variable = (_function_type)GetProcAddress( LZNV_DLL_handle, _literal_function_name_ );\
if (_mp_function_variable == NULL)\
{\
ATLTRACE("\n Exported function not found: %s", _literal_function_name_);\
MessageBox(NULL, L"FATAL ERROR: Dll export not found", L"Error", MB_OK);\
return FALSE;\
}
int32_t _loadDLL()
{
LZNV_DLL_handle = LoadLibrary(LZNV_DLL_Name);
if (LZNV_DLL_handle == NULL)
{
wprintf(L"\n\n ERROR While Loading Encode DLL %s. Error: %s\n", LZNV_DLL_Name, _getLastErrorString());
return _LZNV_ERROR_DLL_NOT_FOUND;
}
IMPORT_DLL_PROCEDURE_(PF_LZNV_DLL_MAIN_FILE, _p_LZNV_DLL_Main_File_funct, LZNV_DLL_MAIN_FILE_, L"Successfully found LZNV Main File Encode/Decode Export function");
IMPORT_DLL_PROCEDURE_(PF_LZNV_DLL_MAIN_BUFFER, _p_LZNV_DLL_Main_Buffer_funct, LZNV_DLL_MAIN_BUFFER_, L"Successfully found LZNV Main Buffer Encode/Decode Export function");
ASSERT(_p_LZNV_DLL_Main_File_funct);
if (!_p_LZNV_DLL_Main_File_funct) {
return _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND;
}
ASSERT(_p_LZNV_DLL_Main_Buffer_funct);
if (!_p_LZNV_DLL_Main_Buffer_funct) {
return _LZNV_ERROR_EXPORTED_MAIN_FUNC_NOT_FOUND;
}
return 0;
}