Aide:DllCall.txt

De Wiki AutoIt Français
Aller à : navigation, rechercher

Document original V3.3.6.1 :

###Function###
DllCall

###Description###
Dynamically calls a function in a DLL.

###Syntax###
DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

###Parameters###
@@ParamTable@@
dll
	The filename of the DLL to use. e.g. "user32.dll". A handle obtained from DllOpen can also be used (See Remarks).
return type
	The return type of the function (see below).
function
	The name, eg. "MessageBox" or the ordinal value, e.g. 62, of the function in the DLL to call.
type1
	[optional] The type of the parameter (see remarks).
param1
	[optional] The actual parameter (see remarks).
type n
	[optional] The type of the nth parameter (see remarks).
param n
	[optional] The actual nth parameter (see remarks).
@@End@@

<br>Valid Types are:

@@ParamTable@@
<b>Type</b>
	<b>Details</b>
none
	no value (only valid for return type - equivalent to void in C)
BYTE
	an unsigned 8 bit integer
BOOLEAN
	an unsigned 8 bit integer
short
	a 16 bit integer
USHORT
	an unsigned 16 bit integer
WORD
	an unsigned 16 bit integer
int
	a 32 bit integer
long
	a 32 bit integer
BOOL
	a 32 bit integer
UINT
	an unsigned 32 bit integer
ULONG
	an unsigned 32 bit integer
DWORD
	an unsigned 32 bit integer
INT64
	a 64 bit integer
UINT64
	an unsigned 64 bit integer
ptr
	a general pointer (void *)
HWND
	a window handle (pointer)
HANDLE
	an handle (pointer)
float
	a single precision floating point number
double
	a double precision floating point number
INT_PTR, LONG_PTR, LRESULT, LPARAM
	an integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
UINT_PTR, ULONG_PTR, DWORD_PTR, WPARAM
	an unsigned integer big enough to hold a pointer when running on x86 or x64 versions of AutoIt.
str
	an ANSI string (a minimum of 65536 chars is allocated).
wstr
	a UNICODE wide character string (a minimum of 65536 chars is allocated).
*
	Add * to the end of another type to pass it by reference.  For example "int*" passes a pointer to an "int" type.
@@End@@


<br>Conversions from Windows API types to AutoIt types:

@@ParamTable@@
<b>WINDOWS API Type</b>
	<b>AutoIt Type</b>
LPCSTR/LPSTR
	str
LPCWSTR/LPWSTR
	wstr
LPVOID
	ptr
LP<i>xyz</i>
	<i>xyz</i>*
HINSTANCE
	handle
HRESULT
	long
LONGLONG/LARGE_INTEGER
	INT64
ULONGLONG/ULARGE_INTEGER
	UINT64
SIZE_T
	ULONG_PTR
@@End@@

To use nested structures inside a structure you must re-define the nested structure.  For example, a structure containing 2 POINT structures ("long;long") would be declared as "long;long;long;long".  The first two long values correspond to the first POINT structure and the second two values correspond to the second POINT structure.

For more Windows API types see <a href="http://msdn.microsoft.com/en-us/library/aa383751.aspx">MSDN</a>.

###ReturnValue###
@@ReturnTable@@
Success:	@error = 0.
Failure:	set @error	
@error:	1 unable to use the DLL file,
	2 unknown "return type",
	3 "function" not found in the DLL file,
	4 bad number of parameters.
@@End@@
See remarks.


###Remarks###
If a dll filename is given then the DLL is automatically loaded and then closed at the end of the call. If you want to manually control the loading and unloading of the DLL then you should use DllOpen and DllClose and use a handle instead of a filename in this function.

By default, AutoIt uses the 'stdcall' calling method. To use the 'cdecl' method place ':cdecl' after the return type.
DllCall("SQLite.dll", "int:cdecl", "sqlite3_open", "str", $sDatabase_Filename , "long*", 0).

By default, AutoIt tries to use the ANSI version of a function name, i.e. MessageBoxA is attempted when MessageBox is given as the function name. To call the unicode version use MessageBoxW.

If the function call fails then @error is set to 1.  Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified when passed by reference).
$return[0] = function return value
$return[1] = param1
$return[2] = param2
...
$return[n] = paramn




###Related###
DllCallbackFree, DllCallbackGetPtr, DllCallbackRegister, DllOpen, DllClose, DllStructCreate, DllStructGetPtr


###Example###
@@IncludeExample@@


Document traduit V3.3.6.1 :

###Function###
DllCall

###Description###
Appelle dynamiquement une fonction dans une DLL.

###Syntax###
DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )

###Parameters###
@@ParamTable@@
dll
	Le nom du fichier de la DLL à utiliser, par exemple "user32.dll". Un handle obtenus à partir de DllOpen peut également être utilisé (voir remarques).
return type
	Le type de retour de la fonction (voir ci-dessous).
function
	Le nom, par exemple. "MessageBox" ou la valeur ordinale, par exemple 62, de la fonction à appeler dans la DLL.
type1
	[optionnel] Le type du paramètre (voir les remarques).
param1
	[optionnel] Le paramètre actuel (voir les remarques).
type n
	[optionnel] Le type du Nème paramètre (voir les remarques).
param n
	[optionnel] Le Nème paramètre actuel (voir les remarques).
@@End@@

<br>Les types valides sont:

@@ParamTable@@
<b>Type</b>
	<b>Détails</b>
none
	aucune valeur (valable uniquement pour le type de retour - l'équivalent de vide dans C)
BYTE
	8 bits entiers non signé
BOOLEAN
	8 bits entiers non signé
short
	16 bits entiers
USHORT
	16 bits entiers non signé
WORD
	16 bits entiers non signé
int
	32 bits entiers
long
	32 bits entiers
BOOL
	32 bits entiers
UINT
	32 bits entiers non signé
ULONG
	32 bits entiers non signé
DWORD
	32 bits entiers non signé
INT64
	64 bits entiers
UINT64
	64 bits entiers non signé
ptr
	un pointeur générale (void *)
HWND
	un handle de fenêtre (pointeur)
HANDLE
	un handle (pointeur)
float
	une simple précision sur la virgule flottante du nombre
double
	une double précision sur la virgule flottante du nombre
INT_PTR, LONG_PTR, LRESULT, LPARAM
	un entier assez grand pour contenir un pointeur lors de l'exécution sur les versions x86 ou x64 de AutoIt.
UINT_PTR, ULONG_PTR, DWORD_PTR, WPARAM
	un entier non signé assez grand pour contenir un pointeur lors de l'exécution sur les versions x86 ou x64 de AutoIt.
str
	une chaîne de caractères ANSI (un minimum de 65536 caractères est attribué).
wstr
	une chaîne de caractères Unicode large (un minimum de 65 536 caractères est attribué).
*
	Ajouter * à la fin d'un autre type de passer par la référence int. Par exemple "int*" passe sur un pointeur de type "int".
@@End@@


<br>Conversions de types de API Windows pour les types de AutoIt:

@@ParamTable@@
<b>Type de l'API Windows</b>
	<b>AutoIt Type</b>
LPCSTR/LPSTR
	str
LPCWSTR/LPWSTR
	wstr
LPVOID
	ptr
LP<i>xyz</i>
	<i>xyz</i>*
HINSTANCE
	handle
HRESULT
	long
LONGLONG/LARGE_INTEGER
	INT64
ULONGLONG/ULARGE_INTEGER
	UINT64
SIZE_T
	ULONG_PTR
@@End@@

Pour utiliser les structures imbriquées à l'intérieur d'une structure, vous devez redéfinir la structure imbriquée. Par exemple, une structure contenant une structure à deux points ("long;long") seraient déclarés comme «longue;longue;longue;longue". Les deux premières valeurs de long correspondent à la structure premier point et la seconde valeur corresponde à la structure du second point.

For more Windows API types see <a href="http://msdn.microsoft.com/en-us/library/aa383751.aspx">MSDN</a>.

###ReturnValue###
Succès:	@ error = 0.
Échec:	définit @error
@error:	1 une incapacité à utiliser le fichier DLL,
	2 "type de retour" inconnu,
	3 la fonction n'a pas été trouvée dans le fichier DLL,
	4 mauvais numéro de paramètres.
@@End@@
Voir les remarques.


###Remarks###
Si un fichier dll est donné, alors la DLL est automatiquement chargé et ensuite fermé à la fin de l'appel. Si vous voulez contrôler manuellement le chargement et le déchargement de la DLL, alors vous devriez utiliser DllOpen et DllClose et l'utilisation du handle au lieu d'un nom de fichier dans cette fonction.

Par défaut, AutoIt utilise la méthode "stdcall". Pour utiliser la méthode "cdecl", placez":cdecl" après le type de retour.
DllCall ("SQLite.dll", "int:cdecl", "sqlite3_open", "str", $sDatabase_Filename ", long*", 0).

Par défaut, AutoIt essaie d'utiliser la version ANSI d'un nom de fonction, c'est à dire que par exemple MessageBoxA est tenté quand MessageBox est donné comme nom de fonction. Pour appeler la version unicode, utilisez MessageBoxW.

Si l'appel de fonction échoue, alors @error est mis à 1. Sinon, un tableau est retourné qui contient la valeur de retour de fonction et une copie de tous les paramètres (y compris les paramètres que la fonction peut avoir modifié lors du passage par référence).
$return[0] = valeur de retour de la fonction
$return[1] = paramètre 1
$return[2] = paramètre 2
...
$return[n] = Nème paramètre




###Related###
DllCallbackFree, DllCallbackGetPtr, DllCallbackRegister, DllOpen, DllClose, DllStructCreate, DllStructGetPtr


###Example###
@@IncludeExample@@


Traducteur : TT22

Contributeurs (pour les modifications avant le Wiki) :