MemoryLoadLibrary


Build in function to load a dll multiple times from Memory.
Based on http://www.joachim-bauch.de/tutorials/load_dll_memory.html

hLibrary:=MemoryLoadLibrary(FilePath)

Parameters

Parameter

Description

FilePath

A path to a file on disk that will be loaded into memory and LoadLibrary from there.

Return Value

Returns handle of Library.

Remarks

This handle can be used to get process address of exported functions for this dll (MemoryGetProcAddress).

Related

AutoHotkey.dll, ahkdll, ahktextdll, ahkReady, addFile, addScript, ahkExec, ahkLabel, ahkFunction, ahkPostFunction, ahkassign, ahkgetvar, ahkTerminate, ahkReload, ahkFindFunc, ahkFindLabel, ahkPause, ahkExecuteLine, Alias, cacheEnable, FindFunc, FindLabel, getTokenValue, getVar, Static, AutoHotkeyMini, DynaCall, CriticalSection, CriticalObject, ResourceLoadLibrary, MemoryGetProcAddress, MemoryFreeLibrary, Other Changes

Example

SetWorkingDir % A_ScriptDir
; Similar to DllCall("LoadLibrary",...)
dll:=MemoryLoadLibrary("AutoHotkey.dll")

; Similar to DllCall("GetProcAddress",...)
ahktextdll:=MemoryGetProcAddress(dll,"ahktextdll")
ahkTerminate:=MemoryGetProcAddress(dll,"ahkTerminate")

; Call exported function
DllCall(ahktextdll,"Str","MsgBox","Str","","Str","","Cdecl UInt")
MsgBox Thread running
DllCall(ahkTerminate,"Int",0) ;exit thread
; Free Library from Memory
MemoryFreeLibrary(dll)