PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Using the API Description variables
  • Properties specific to the description of API Description variables
  • Special cases
  • Functions that use the API Description variables
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
API description (Type of variable)
In French: Description d'API
An API Description variable is used to describe an API, its parameters, its return value and its calling options by programming.
The characteristics of this type can be defined and modified by several WLanguage properties.
Note: See Declaring a variable for more details.
Example
GetModuleHandle is API Description
GetModuleHandle..DLLName = "kernel32"
GetModuleHandle..FunctionName = "GetModuleHandleA"
GetModuleHandle..ReturnType = apiSystemInt
GetModuleHandle..Parameter[1]..Type = apiString
// Call a fictitious DLL for calculating the distance between 2 points on the surface of the Earth
CalculateDistance is API Description
CalculateDistance..DLLName = "GEO.DLL"
CalculateDistance..FunctionName = "CalculateDistance"
CalculateDistance..Parameter[1]..Type = apiReal_8
CalculateDistance..Parameter[2]..Type = apiReal_8
CalculateDistance..Parameter[3]..Type = apiReal_8
CalculateDistance..Parameter[4]..Type = apiReal_8
CalculateDistance..ReturnType = apiReal_8

distance is real = CalculateDistance(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 = apiString

    // Direct use
    GetModuleHandle(Null)
  • with API. For example:
    GetModuleHandle is API Description
    GetModuleHandle..DLLName = "kernel32"
    GetModuleHandle..FunctionName = "GetModuleHandleA"
    GetModuleHandle..ReturnType = apiSystemInt
    GetModuleHandle..Parameter[1]..Type = apiString

    // Use of the API function
    API(GetModuleHandle, Null)

Properties specific to the description of API Description variables

The following properties can be used to handle an API Description:
Property nameType usedEffect
AddressSystem integerAddress of the function.
If this property is specified, ..FunctionName contains the address of the function, ..Number is set to -1 and ..DLLName is set to "" (empty string).
Versions 18 and later
CallingConvention
New in version 18
CallingConvention
CallingConvention
Integer constantMethod for calling the DLL. Three call conventions are available via the following constants:
  • Versions 18 and later
    CDECL
    New in version 18
    CDECL
    CDECL
  • Versions 18 and later
    STDCALL
    New in version 18
    STDCALL
    STDCALL
  • Versions 18 and later
    THISCALL
    New in version 18
    THISCALL
    THISCALL
DLLNameCharacter stringName of the DLL.
FunctionNameCharacter stringName of the function found in the DLL.
If this property is specified, ..DLLName must also be specified. In this case, ..Number is set to -1 and ..Address is set to 0.
NumberIntegerNumber of the function.
If this property is specified, ..DLLName must also be specified. In this case, ..FunctionName 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:
  • apiLockThreads: If this constant is used, the call to the API locks all the current threads. This is used to protect the external DLL from the multi-thread calls.
  • apiFreeDLL: If the DLL was 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.
  • apiRestoreSystemSettings: If this constant is used, the system parameters will be restored after the call to the API. Indeed, some APIs modify the system parameters.
The default options are apiRestoreSystemSettings + apiFreeDLL.
ParameterArrayType of each parameter of the API. This property corresponds to the following constants:
  • apiBoolean: the parameter is a boolean.
  • apiBuffer: the parameter is a buffer.
  • apiCharacter: the parameter is a character.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.
    Windows Mobile the parameter is always a Unicode character.
  • Versions 17 and later
    apiAnsiCharacter: the parameter is an Ansi character.
    New in version 17
    apiAnsiCharacter: the parameter is an Ansi character.
    apiAnsiCharacter: the parameter is an Ansi character.
  • Versions 17 and later
    apiUnicodeCharacter: the parameter is a Unicode character
    New in version 17
    apiUnicodeCharacter: the parameter is a Unicode character
    apiUnicodeCharacter: the parameter is a Unicode character
  • apiString: the parameter is a character string.apiString: the parameter is an Ansi character string if the project is in Ansi mode, the parameter is a Unicode character string if the project is in Unicode mode.
    Windows Mobile the parameter is always a Unicode character string.
  • apiAnsiString: the parameter is an Ansi character string.
  • apiUnicodeString: the parameter is a Unicode character string.
  • apiInt_4: the parameter is a 4-byte integer.
  • apiInt_8: the parameter is an 8-byte integer.
  • apiSystemInt: the parameter is a system integer.
  • apiReal_4: the parameter is a 4-byte real.
  • apiReal_8: the parameter is a 8.-byte real
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 a character.apiCharacter: the API returns an Ansi character if the project is in Ansi mode, a Unicode character if the project is in Unicode mode.
    Windows Mobile the API always returns a Unicode character.
  • Versions 17 and later
    apiAnsiCharacter: the API returns an Ansi character.
    New in version 17
    apiAnsiCharacter: the API returns an Ansi character.
    apiAnsiCharacter: the API returns an Ansi character.
  • Versions 17 and later
    apiUnicodeCharacter: the API returns a Unicode character.
    New in version 17
    apiUnicodeCharacter: the API returns a Unicode character.
    apiUnicodeCharacter: the API returns a Unicode character.
  • apiString: the API returns a character string.apiString: the API returns an Ansi character string if the project is in Ansi mode, a Unicode character string if the project is in Unicode mode.
    Windows Mobile the parameter is always a Unicode character string.
  • apiAnsiString: the API returns an Ansi character string.
  • apiUnicodeString: the API returns a Unicode character string.
  • apiInt_4: the API returns a 4-byte integer.
  • apiInt_8: the API returns an 8-byte integer.
  • apiSystemInt: the API returns a system integer.
  • apiReal_4: the API returns a 4-byte real.
  • apiReal_8: the API returns a 8.-byte real
Note: These properties can be used with one of the following syntaxes:
  • <Variable Name>..<Property Name>
  • <Variable Name>.<Property Name>

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 the API Description variables

The following functions can be used to handle an API Description:
Versions 09 and later
API
New in version 09
API
API
Runs a function found in an external DLL.
Versions 09 and later
CallDLL32
New in version 09
CallDLL32
CallDLL32
Runs a function found in an external DLL.
Minimum required version
  • Version 16
This page is also available for…
Comments
Click [Add] to post a comment