AUTOIT calls DLL

note:

The dll library interface called by Autoit needs to be written in C, which means that the function called is the syntax and definition of C

Mainly used functions

DllCall ( "dll", "return type", "function" [, type1, param1 [, type n, param n]] )
DllStructCreate ( Struct [, Pointer] )//创建C/C++的数据结构变量,供DllCall使用
DllStructSetData ( Struct, Element, value [, index] )//设置变量数值
DllStructGetData ( Struct, Element [, index = Default] )//得到变量数值

Practical application

Suppose the path of the dll to be called is d:/testdll/TestFuns.dll, and the function to be called is declared as

float TestFun(char *sFileName, int *x, float *y, int z) //y为数组指针,大小为1024,作为输出参数,x和z是输入参数

1. Define variables

Local $sFileName = "d:/test.txt"
Local $tX =DllStructCreat("int")  
Local $tY =DllStructCreat("float[1024]")  
Local $iZ
Local $Dll = "d:/testdll/TestFuns.dll"
Local $fResult[1024]

2. Call

DllCall($Dll, "float:cdecl", "TestFun", "struct*",  $tX, "struct*", $tY, "int", $iZ)

3. Get the result

for $i = 1 To 1024
	$fResult[$i-1] = DllStructGetData($tY, 1, $i)
Next

End

Guess you like

Origin blog.csdn.net/coinv2014/article/details/107634632