AutoIt DLL预加载可能吗?

时间:2017-09-07 10:17:04

标签: dll autoit

有没有比每次打开和调用.dll文件更好的方法?

<label>
  <bv-checkbox ng-model="i.checked" ng-change="inputChanged()""></bv-checkbox>
  <span ng-bind="i.displayName"></span>
<label>

在AutoHotkey中,可以预加载.dll文件。这在AutoIt中是否也可以(为了节省性能)?

1 个答案:

答案 0 :(得分:1)

  

有没有比每次打开和调用.dll文件更好的方法?

加载并关闭.dll文件一次(与每个函数调用相反)。示例(未经测试):

Global Const $g_sFileDll      = 'MyFirstDll.dll'
Global Const $g_sErrorDllLoad = 'Failed to load .dll file.' & @LF
Global Const $g_sErrorDllCall = 'Failed to call .dll file.' & @LF
Global Const $g_iCountDllCall = 10
Global Const $g_iDelayDllCall = 1000

Global       $g_hDLL          = DllOpen($g_sFileDll)

If $g_hDLL = -1 Then    
    ConsoleWrite($g_sErrorDllLoad)
    Exit    
EndIf

For $i1 = 1 To $g_iCountDllCall
    getLife($g_hDLL)
    Sleep($g_iDelayDllCall)    
Next

DllClose($g_hDLL)
Exit

Func getLife(ByRef $hDLL)
    Local $aResult = DllCall($hDLL, "int:cdecl", "getLife")

    If @error Then    
        ConsoleWrite($g_sErrorDllCall)    
    Else    
        ConsoleWrite('Result: ' & $aResult[0] & @LF)    
    EndIf

EndFunc