<< Click to Display Table of Contents >> Navigation: ThinBASIC Core Language > Script structure > External function declarations > CallDWord |
Description
Invoke a Sub or Function indirectly using a pointer to a binary exported function or a sub, usually from an external DLL.
Syntax
CALLDWORD PtrToSubOrFunction USING abc([arguments])
Returns
None
Parameters
Name |
Type |
Optional |
Meaning |
PtrToSubOrFunction |
Number |
No |
Numeric expression containing the pointer to a |
abc... |
No |
name of a sub or function previously declared with DECLARE statement |
Remarks
Restrictions
See also
Examples
DECLARE FUNCTION GetProcAddress LIB "Kernel32.dll" ALIAS "GetProcAddress" (BYVAL hModule AS DWORD, lpProcName AS ASCIIZ) AS LONG
DECLARE FUNCTION FreeLibrary LIB "Kernel32.dll" ALIAS "FreeLibrary" (BYVAL hLibModule AS DWORD) AS LONG
DECLARE FUNCTION LoadLibraryA LIB "Kernel32.dll" ALIAS "LoadLibraryA" (lpLibFileName AS Asciiz) AS DWORD
DECLARE FUNCTION LoadLibraryW LIB "Kernel32.dll" ALIAS "LoadLibraryW" (lpLibFileName AS Asciiz) AS DWORD
DECLARE FUNCTION MessageBoxW (
BYVAL hWnd AS DWORD ,
byval lpText AS Asciiz,
byval lpCaption AS Asciiz,
BYVAL dwType AS DWORD
) AS LONG
DECLARE FUNCTION MessageBoxA (
BYVAL hWnd AS DWORD ,
byval lpText AS Asciiz,
byval lpCaption AS Asciiz,
BYVAL dwType AS DWORD
) AS LONG
uses "UI"
DWord hLib
DWord hProc
hLib = LoadLibraryA("User32.dll")
IF hLib THEN
hProc = GetProcAddress(hLib, "MessageBoxA")
IF hProc THEN
CALLDWORD hProc USING MessageBoxA(0, "Simple Ansi Msg from API", "Win32 Rocks", %MB_OK)
ELSE
'---Error
END IF
FreeLibrary hLib
Else
'---Error
END IF