ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Miscellaneous Windows functions
  • Using the API Description variables
  • Properties specific to API Description variables
  • Special cases
  • Functions that use API Description variables
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
API description (Variable type)
In french: Description d'API
An API Description variable is used to describe an API, its parameters, its return value and its calling options programmatically.
You can define and change the characteristics of this type using different WLanguage properties.
Note: For more details on the declaration of this type of variable and the use of WLanguage properties, see Declaring a variable.
Example
GetModuleHandle is API Description
GetModuleHandle.DLLName = "kernel32"
GetModuleHandle.FunctionName = "GetModuleHandleA"
GetModuleHandle.ReturnType = apiSystemInt
GetModuleHandle.Parameter[1].Type = apiAnsiString
// Appel d'une DLL fictive de calcul de distance entre deux points à la surface de la Terre
CalculeDistance is API Description
CalculeDistance.DLLName = "GEO.DLL"
CalculeDistance.FunctionName = "CalculeDistance"
CalculeDistance.Parameter[1].Type = apiReal_8
CalculeDistance.Parameter[2].Type = apiReal_8
CalculeDistance.Parameter[3].Type = apiReal_8
CalculeDistance.Parameter[4].Type = apiReal_8
CalculeDistance.ReturnType = apiReal_8

distance is real = CalculeDistance(Latitude1, Longitude1, Latitude2, Longitude2)
Remarks

Using the API Description variables

The API description variables can be used:
  • directly, by specifying the values of the different parameters if necessary. For example:
    GetModuleHandle is API Description
    GetModuleHandle.DLLName = "kernel32"
    GetModuleHandle.FunctionName = "GetModuleHandleA"
    GetModuleHandle.ReturnType = apiSystemInt
    GetModuleHandle.Parameter[1].Type = apiAnsiString
    // Utilisation directe
    GetModuleHandle(Null)
  • with the API function. For example:
    GetModuleHandle is API Description
    GetModuleHandle.DLLName = "kernel32"
    GetModuleHandle.FunctionName = "GetModuleHandleA"
    GetModuleHandle.ReturnType = apiSystemInt
    GetModuleHandle.Parameter[1].Type = apiAnsiString
    // Utilisation de la fonction API
    API(GetModuleHandle, Null)

Properties specific to API Description variables

The following properties can be used to handle an API Description:
Property nameType usedEffect
AddressSystem integerAddress of the function.
If a value is assigned to this property, the FunctionName property contains the address of the function, the Number property is set to -1 and the DLLName property is set to "" (empty string).
CallingConventionInteger constantMethod for calling the DLL. Three call conventions are available via the following constants:
  • CDECL
  • STDCALL
  • THISCALL
DLLNameCharacter stringDLL name.
FunctionNameCharacter stringName of the function found in the DLL.
If this property is specified, the DLLName property must also be specified. In this case, the Number property is set to -1 and the Address property is set to 0.
NumberIntegerNumber of the function.
If this property is specified, the DLLName property must also be specified. In this case, the FunctionName property contains the number and Address is reset to 0.
OptionInteger constantOptions for calling the API. This property can correspond to one of the following constants:
  • apiBlockThreads If this constant is used, the API call blocks all current threads. This is used to protect the external DLL from the multi-thread calls.
  • apiDownloadDLL If the DLL has been loaded to call the API, it will be unloaded. This constant is ignored if the DLL was already loaded during the call to the API.
  • apiRestaureSystemParameters If this constant is used, system parameters are restored after calling the API. Indeed, some APIs modify the system parameters.
The default options are apiRestoreSystemSettings + apiFreeDLL.
ParameterArrayThe Type property of each element of the array indicates the type of each API parameter. This property can correspond to:
  • a structure name in string form if the parameter is a structure passed as a parameter by value,
  • one of the following constants:
    • apiBoolean parameter is a boolean.
    • apiBuffer parameter is a buffer.
    • apiCharacter the parameter is an Ansi character if the project is in Ansi mode, the parameter is a Unicode character if the project is in Unicode mode.
    • apiAnsiCharacter parameter is an Ansi character.
    • apiUnicodeCharacter parameter is a Unicode character
    • apiString the parameter is an Ansi string if the project is in Ansi mode, the parameter is a Unicode string if the project is in Unicode mode.
    • apiAnsiChain parameter is an Ansi character string.
    • apiUnicode string parameter is a Unicode character string.
    • apiInteger_1 parameter is an integer over 1.
    • apiInteger_2 parameter is an integer over 2.
    • apiInteger_4 parameter is an integer over 4.
    • apiInteger_8 parameter is an integer over 8.
    • apiInteger_1 parameter is unsigned int over 1.
    • apiSignFreeInteger_2 parameter is unsigned int over 2.
    • apiSignFreeInteger_4 parameter is unsigned int over 4.
    • apiIntegerUnsigned_8 parameter is unsigned int over 8.
    • apiSystemInteger parameter is a system integer.
    • apiReal_4 parameter is a real number out of 4.
    • apiReal_8 parameter is a real number out of 8.
ReturnTypeInteger or stringType returned by the API. This property corresponds to:
  • apiBoolean the API returns a Boolean.
  • apiBuffer the API returns a buffer.
  • apiCharacter The API returns an Ansi character if the project is in Ansi mode, a Unicode character if the project is in Unicode mode.
  • apiAnsiCharacter the API returns an Ansi character.
  • apiUnicodeCharacter the API returns a Unicode character.
  • apiString the API returns an Ansi string if the project is in Ansi mode, a Unicode string if the project is in Unicode mode.
  • apiAnsiChain The API returns an Ansi string.
  • apiUnicode string the API returns a Unicode string.
    • apiInteger_1 API returns an integer over 1.
    • apiInteger_2 API returns an integer of 2.
    • apiInteger_4 API returns an integer out of 4.
    • apiInteger_8 API returns an integer out of 8.
    • apiSignFreeInteger_1 API returns an unsigned integer over 1.
    • apiSignFreeInteger_2 API returns an unsigned integer over 2.
    • apiSignFreeInteger_4 API returns an unsigned integer over 4.
    • apiSignFreeInteger_8 API returns an unsigned integer over 8. *apiSystemInteger the API returns a system integer.
  • apiReal_4 API returns a real number out of 4.
  • apiReal_8 API returns a real number out of 8.

Special cases

  • An API Description variable must be declared for each function used.
  • The DLL is loaded once only, and not for each variable.

Functions that use API Description variables

The following functions can be used to handle API Description variables:
APIRuns a function found in an external DLL.
CallDLL32Runs a function found in an external DLL.
Minimum version required
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/27/2025

Send a report | Local help