call
Invokes a procedure by its address.
' Load the user32.dll
dim hLib as sys = LoadLibrary("user32.dll")
' Get the address of the MessageBoxA procedure
dim proc as sys = GetProcAddress(hLib, "MessageBoxA")
' Call the procedure by its address
call proc(0,"Hello World", "MessageBoxA", 0)
' Free the library
freelibrary hLib
From what I have learned with bind, I can also use this instead of call.
' Load the user32.dll
dim hLib as sys = LoadLibrary("user32.dll")
' Get the address of the MessageBoxA procedure
dim proc as sys = GetProcAddress(hLib, "MessageBoxA")
' Attach a function prototype to the address of MessageBox.
declare MessageBox(sys hWnd, char* lpText, char* lpCaption, dword uType) as int at proc
' Invoke the procedure
MessageBox 0,"Hello World", "MessageBoxA", 0
' Free the library
freelibrary hLib
There is also an example (ExplicitType.02bas) that uses call:
'========================
'EXPLICIT TYPE CONVERSION
'========================
'this can be used for procedure calls without prototypes
function fs(single a, b) external
'--------------------------------
print a+b
end function
function fd(double a, b) external
'--------------------------------
print a+b
end function
'SETUP ANONYMOUS PROCEDURES BY USING A SYS VARIABLE AS A POINTER
'===============================================================
sys g
'implicit double with decimal point
'==================================
g=@fs 'anonymise
call g 1.2, 15.25+1.0 'default single
'implicit single
'===============
g=@fs 'anonymise
single a=4.5, b=8.25
call g a, a+b
'explicit double
'===============
g=@fd 'anonymise
call g convert double 1, convert double 10