Hi,
Is it possible to call a procedure in the host/main program from a DLL, both of which were programmed in PB?
Thanks.
Call host program procedure from DLL?
Re: Call host program procedure from DLL?
Use a passed pointer reference and a prototype.
Re: Call host program procedure from DLL?
I don't really know how to do that. What am I doing wrong? I get Invalid Memory Access when trying to pass the procedure.
Library
Code: Select all
Procedure MyFunction(param.i)
Debug param
EndProcedure
Prototype InitLib(*func)
Prototype LibFunc(param.i)
OpenLibrary(0, "test.dylib")
Global InitLib.InitLib = GetFunction(0, "Init")
Global LibFunc.LibFunc = GetFunction(0, "Func1")
InitLib(@MyFunction())
LibFunc(5)
Code: Select all
Prototype HostFunc(param1.i)
Global HostFunc.HostFunc
Procedure Init(*func)
HostFunc = *func
EndProcedure
Procedure Func1(param1.i)
HostFunc(param1)
EndProcedure
Re: Call host program procedure from DLL?
Oops, stupid oversight.