Posted: Tue Jan 04, 2005 9:02 pm
So a C++ function exposed in a DLL can be called using CallFunction after Loading the DLL?
[edit]NM, thanks for you help I got it!
[edit]NM, thanks for you help I got it!
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
If (lib = OpenLibrary(#PB_Any, "SomeLib.dll")) = 0
End
EndIf
If(ExamineLibraryFunctions(lib))
While(NextLibraryFunction)
Debug LibraryFunctionName()
Wend
Else
Debug "No Functions found"
EndIfYes, i am actually writing C++ code in a DLL for a PureBasic soundeditor, there are no limitations using this methoddracflamloc wrote:So a C++ function exposed in a DLL can be called using CallFunction after Loading the DLL?
Code: Select all
#ifdef __cplusplus
extern "C" {
#endif
void DoAll()
{
/* [...] */
}
#ifdef __cplusplus
}
#endif
Code: Select all
ProcedureDLL.l i3D_Initialize3D(width.l,height.l,bits.l,isFullscreen.l)
OpenLibrary(20,".\PB_Irrlicht.dll")
If IsLibrary(20)
tmp.l=CallFunction(20,"?pb_Initialize3D@@YAHHHHH@Z",width,height,bits,isFullscreen)
ProcedureReturn tmp
Else
ProcedureReturn 0
EndIf
EndProcedure
//heres the C++ function
IRRLICHT_API int IRRCALLCONV pb_Initialize3D(int width,int height,int bits,int isFullscreen)
{
pb_device = irr::createDevice(video::EDT_OPENGL,dimension2d<s32>(width,height),bits,pb_intToBool(isFullscreen),true,false);
if (pb_device==0)
return 0;
//get video driver and scene manager and gui
pb_driver = pb_device->getVideoDriver();
pb_scene = pb_device->getSceneManager();
pb_gui = pb_device->getGUIEnvironment();
pb_scene->addCameraSceneNode(0,vector3df(0,0,0),vector3df(0,0,0));
return 1;
}
Code: Select all
#define IRRLICHT_API __declspec(dllexport)