It would be easier to understand for general use with AutoHotkey and especially for beginners.
DllOpen(LibFileName) (calls LoadLibrary function)
Code: Select all
/*
Function .......: DllOpen(LibFileName)
Parameters .....: LibFileName -> The name of the module. This can be either a library module (a .dll file) or an executable module (an .exe file).
Return Value ...: - If the function succeeds, the return value is a handle to the module.
- If the function fails, the return value is NULL.
AHK Source .....: Calls internally LoadLibrary function
*/
hModule := DllOpen("DllFile.dll")
DllClose(hLibModule) (calls FreeLibrary function)
Code: Select all
/*
Function .......: DllClose(hLibModule)
Parameters .....: hLibModule -> A handle to the loaded library module.
Return Value ...: - If the function succeeds, the return value is nonzero.
- If the function fails, the return value is zero.
AHK Source .....: Calls internally FreeLibrary function
*/
DllClose(hModule)
Example Codes:
Code: Select all
; loads the specified module (bcrypt) into the address space of the calling process
hBCRYPT := DllOpen("bcrypt.dll")
; some code with the bcrypt library
DllCall("bcrypt\BCryptOpenAlgorithmProvider", "ptr*", hAlg, "ptr", &BCRYPT_SHA512_ALGORITHM, "ptr", 0, "uint", 0)
; frees the loaded module (bcrypt) and, if necessary, decrements its reference count (cleaning up resources)
DllClose(hBCRYPT)
Code: Select all
; loads the specified module (sqlite) into the address space of the calling process
hSQLITE := DllOpen(A_ScriptDir "\" (A_PtrSize = 8 ? "x64" : "x86") "\sqlite3.dll")
; some code with sqlite
Version := StrGet(DllCall("sqlite3.dll\sqlite3_libversion", "Cdecl UPtr"), "UTF-8")
; frees the loaded module (sqlite) and, if necessary, decrements its reference count (cleaning up resources)
DllClose(hSQLITE)