Older Newer
Thu, 30 Dec 2021 08:31:46 . . . . SyneRyder [Initial function definition]


Changes by last author:

Added:
= fCallLibFmc =

Requires FM 1.0 Beta 9.0 (April 2008) or newer

== Syntax ==

:double fCallLibFmc(void *fnptr, ...)

== Arguments ==

:fnptr

::A pointer (obtained with getLibFn) to the DLL function to call.

:...

::The other parameters required by the DLL function (varies depending on the function).

== Return ==

:Returns the return double value of the called DLL function, which varies depending on the function called.

== Description ==

:Calls a function in a DLL that has previously been loaded with loadLib and getLibFn, except that the first argument (fnptr) is replaced by a pointer to the FMcontext record (fmcp) that you can then access from your DLL function. The structure of FMcontext can be found in the FilterMeister source code in the AfhFMcontext.h file. As the context record can change between FilterMeister versions, it is important that your DLL is designed to use the correct version of the context record for your plugin.

== Comment ==

:In most cases, you would use the callLib or callLibFmc functions. Only use fCallLibFmc if the DLL function you are calling returns a double value, and if you need access to the FilterMeister Context Record to access FM functions and variables from your DLL.

== Example ==

Example of called functions in a DLL:

<code>

__declspec(dllexport)

int MyForEveryTile(FMcontext *fmcp, int X, int Y) { return false; }

__declspec(dllexport)

double MyFloat(FMcontext *fmcp, int a, double x, double y) {

return a*(x - y);

}

</code>

To invoke these functions from FM:

<code>

int g_hMyDll = loadLib("MyDll");

if (!g_hMyDll) ERROR...

int g_pfnMyForEveryTile = getLibFn(g_hMyDll, "MyForEveryTile");

if (!g_pfnMyForEveryTile) ERROR...

int g_pfnMyFloat = getLibFn(g_hMyDll, "MyFloat");

if (!g_pfnMyFloat) ERROR...

int iRes = callLibFmc(g_pfnMyForEveryTile, 100, 200);

double fRes = fcallLibFmc(g_pfnMyFloat, 10, 1.2, 3.14);

</code>

== See Also ==

:callLib, loadLib, getLibFn, callLibFmc, fcallLib, freeLib