Navigation:  Tutorial >

The ot4xb nFpCall() function

Previous pageReturn to chapter overviewNext page

nFpCall() allow to call dynamically a function  stored in a DLL

 

1.- nFpCall() can work using a function pointer, p.e. obtained  with the function nGetProcAddress(), with a template obtained with DllPrepareCall(), or also with a DllName/FunctionName pair inside an array.

 

2.- nFpCall() manage automatically  STDCALL and CDECL calling conventions, so you not need to specify it.

 

3.- After nFpCall() you can retrieve the value of the last windows error using nFpGetLastError()

 

4 .- nFpCall() support a lot of extended types, and even you can provide a Xbase++ array of integers when a pointer to a simple structure is required.

 

5 .-When the called DLL function return a double floating point or  64 bit integer value, ot4xb provide 2 specialized variants of nFpCall(): ndFpCall() and qwFpCall()

 

ot4xb.ch provides also a command based on nFpCall() to make it still more simple and intuitive:

#xtranslate @<dll>:<fn>([<p1>] [,<pn>] ) => ;

            nFpCall( {<(dll)>,<(fn)>} [,<p1>] [,<pn>] )

 

Now you can can call the user32.dll function GetDesktopWindow() in this way:

@user32:GetDesktopWindow()

 

Now we will build the previous example to retrieve the bounding rectangle of the windows desktop, but this time using the ot4xb command  @<dll>:<function>() .

 

function aGetDesktopRect( lOk )

local aRect := {0,0,0,0}

local hDesktop :=  @user32:GetDesktopWindow()

lOk := ( @user32:GetWindowRect( hDesktop , @aRect) != 0 )

if lOk

   return aRect

end

return NIL

 

The array aRect will hold our RECT structure, so we just need to pass it by reference.