Navigation:  Reference > Functions By Category > DLL and Calls >

nFpCall()

Previous pageReturn to chapter overviewNext page

Call a STDCALL or CDECL function returning a 32 bit value from a provided pointer, converting the parameters as required.

Syntax:

nFpCall( <fp> , params ... ) -> n32BitResult

 

Parameters:

<fp>

If numeric must be a function pointer like the result of nGetProcAddress().

If a string must be the result of DllPrepareCall()

 

<params ... >

Required parameters of the called function.

Return Value:

nFpCall() will return always a 32 bit integer value.

BOOL functions will return 0 when .F. or any other value meaning .T.

 

Notes:

If the function returns a 32 bit float value you must convert it using UnPackFloat32()
To get 64 bit integer values use the specialiced function qwFpCall() instead of this one.
To get 64 bit float values use the specialiced function ndFpCall()  instead of this one.

 

Calling conventions:

This function support CDECL and STDCALL calling conventions. The calling convention is detected on the fly and the stack are restored according with the right calling convention.

FASTCALL and THISCALL are not supported by this function.

 

Parameter type conversion:

<Xbase++ LOGICAL by value>

The value of the parameter will be passed as BOOL to the called function.

 

<Xbase++ LOGICAL by reference>

A reference pointer to this parameter will be passed as BOOL* to the called function and updated when the function return.

 

<Xbase++ NUMERIC by value>

The value of the parameter will be passed as LONG to the called function. Decimal values will be truncated. You can call also parameters prototyped as shorter values like WORD , __int16 , BYTE or CHAR because CDECL and STDCALL pass the values in 32 bit packs, so the high part will be ignored in this cases.

 

<Xbase++ NUMERIC by reference>

A reference pointer to this parameter will be passed as LONG* to the called function and updated when the function return. If you call parameters prototyped as pointer to shorter values like WORD* , __int16* , BYTE* or CHAR* you will need to adjust the result manually after the call using functions LoWord() or LoByte()

 

<Xbase++ CHARACTER by value>

The value of the parameter will be passed as a READ-ONLY BUFFER ( LPCSTR ) to the called function.

<Xbase++ CHARACTER by reference>

The value of the parameter will be passed as a READ-WRITE BUFFER ( LPSTR ) to the called function.

 

Providing 64 bit integer parameters:

NIL + <Xbase++ CHARACTER by value>

This a special case used to provide __int64 values to the called function. In this case the string MUST have 8 BYTES corresponding to the binary reprentation of the 64 bit integer. You can convert numeric double values to a 64 bit binary integers using the function Double2LongLong()

 

NIL + <Xbase++ CHARACTER by reference>

Same as above but the value will be passed as __int64* and the result will be writed back after the functions returns.

 

Providing float double values:

NIL + <Xbase++ NUMERIC by value>

This a special case used to provide float double values to the called function.

 

NIL + <Xbase++ NUMERIC by reference>

Same as above but the value will be passed as double* and the result will be writed back after the functions returns.

 

Providing 32 bit float values:

You can provide 32 bit float values packed as Xbase++ numeric values with the function PackFloat32() or pointer to 32 bit float passing them by reference.

 

OT4XB Extended pointers:

OT4XB allow you to provide pointers to structures in an easy way using arrays and objects.

 

<Xbase++ ARRAY of NUMERICs>

If you provide an Xbase++ array of numeric values will be passed to the called function as buffer containing an array of int32 values. If passed by reference the buffer values will be written back to your array.

 

<OT4XB GWST OBJECTs >

If you provide a GWST subclass instance like created with structure commands the pointer to the struture will be provided to the called function.