Creating the DLL

Previous  Next

 

To be recognized as an Extension library, the DLL must export the 2 functions

 

mb_ext_load

mb_ext_unload

 

If you use MS Visual Studio make sure there is no function name decorations so use extern "C" when exporting the names.  Use mb_ext_load to register the functions when the DLL is loaded and then remove the functions when it is unloaded in mb_ext_unload.  The 3rd parameter of mb_register_func is the addess of a callback function that will be called when the function is being invoked.  This function will parse any parameters and implement the function.

 

Example:

 

/////////////////////////////////////////////////////////////////////////////

// Function Callback

int _my_function_callback( mb_interpreter_t* s, void** l )

{

  // Parse and process....

 

  return MB_FUNC_OK;

}

 

/////////////////////////////////////////////////////////////////////////////

// Load and Register Functions

extern "C" __declspec(dllexport) int mb_ext_load( mb_interpreter_t* s )

{

  mb_register_func( s, "MYFUNCTION", _my_function_callback )

}

 

/////////////////////////////////////////////////////////////////////////////

// Remove regsitered functions

extern "C" __declspec(dllexport) int mb_ext_unload( mb_interpreter_t* s )

{

  mb_remove_func( s, "MYFUNCTION" );

}