Requires: gfawinx.lg32
Returns the address of an exported function or variable from the specified dynamic-link library (DLL).
addr = GetProcAddr(dllname, expname)
addr | : integer or large variable |
dllname, expname | : string expression |
GetProcAddr retrieves the address of an exported function expname from the dynamic-link library specified in dllname. The parameter expname may also be used to specify the function's ordinal value by using # in front of number.
GetProcAddr returns a large where the low-DWORD contains the address of the exported function or variable and the high-DWORD contains the module handle of the loaded library. If the module handle isn’t required simply store the return value in a Long.
$Library "gfawinx"
Local Long pfnMonFromWin
pfnMonFromWin = GetProcAddr("user32.dll", "MonitorFromWindow")
Trace Hex(pfnMonFromWin)
Local GetMonInfoL As Large, pfnGetMonInfo As Long
GetMonInfoL = GetProcAddr("user32.dll", "GetMonitorInfoA")
pfnGetMonInfo = LoLarge(GetMonInfoL)
Trace Hex(pfnGetMonInfo)
Trace Hex(HiLarge(GetMonInfoL))
Debug.Show
GetProcAddr loads a library only once, regardless the number of times it is used for the same DLL; hence, if the DLL is already in memory the reference count isn’t incremented. If a DLL isn’t loaded yet, GetProcAddr calls the LoadLibrary API, which loads the library and increments the reference count. If the library isn’t used after a call to GetProcAddr the application may discard the library by calling the FreeLibrary() API specifying the handle stored in the high DWORD of the return value. If the library is used after GetProcAddr the application may ignore the high DWORD of the Large. The DLL will be released when the program terminates. .
{Created by Sjouke Hamstra; Last updated: 11/08/2019 by James Gaite}