AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de Windows / Funciones varias de Windows
  • Using the API Description variables
  • Properties specific to API Description variables
  • Special cases
  • Functions that use API Description variables
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
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.
Ejemplo
GetModuleHandle is API Description
GetModuleHandle.DLLName = "kernel32"
GetModuleHandle.FunctionName = "GetModuleHandleA"
GetModuleHandle.ReturnType = apiSystemInt
GetModuleHandle.Parameter[1].Type = apiAnsiString
// 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)
Observaciones

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
    // Direct use
    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
    // Use of the API function
    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.
Versión mínima requerida
  • Versión 16
Esta página también está disponible para…
Comentarios
Haga clic en [Agregar] para publicar un comentario

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local