CallAddress - Call a C function

Top  Previous  Next


<nReturnValue> := CallAddress( <nAddress> {,<nLongParameter1..N>}  )




Address of function to call.




Parameters to be passed to the called function. Each parameter must be a numeric in the LONG range.

Return value

The return value of the called C function.


CallAddress calls a C function at the  address <nAddress> and the optional parameters <nLongParameter1..N> are passed as parameters to this function. Each parameter passed must be a LONG value. CallAddress can be used to call C functions adhering to the __stdcall or __cdecl calling convention.


For a more detailed description refer to Straight C Calls.


The number of parameters  (<nLongParameter1..N>) must exactly match the number of parameters expected by the called function. On return from the called function the stack will be fixed if the parameter count does not match, but passing too low a number of parameters will result in indefinite values for the missing ones being passed in to the called function. If reference parameters are among them, memory corruption will most likely occur.




Calls and callbacks

Quick Info

Library: cckptcor.lib / cckptcor.dll








LOCAL callbackAddress


* Create a callback for a function to be called via CallAddress

callbackAddress := Callback({|a,b,c|MyCallback(a,b,c)},CALLBACK_CALLCONVENTION_STDCALL)


* Call the function via its address passing some test parameters

? CallAddress(callbackAddress,1,2,3)





* Function to be called via CallAddress

STATIC FUNCTION MyCallback(a,b,c)


* Display the parameters passed

? a,b,c


* Return the sum

RETURN a+b+c