Oxygen Basic
Programming => Problems & Solutions => Topic started by: José Roca on October 04, 2018, 05:42:57 PM
-
bind a list of procedures from a Dynamic Link Library (DLL)
USE: for low level (without protoype) calls to DLL functions. the first name is the one used in the program. The second is the name used in the DLL.
' sys Kernel32
kernel32=LoadLibrary "kernel32.dll"
RESULT:
"the first column of keywords is recognised as procedure calls."
Which column?
A prototype may be attached to any of these keywords later.
How?
-
This an example of binding. A full Messagebox prototype is then attached.
sys kernel32=LoadLibrary `kernel32.dll`
sys user32=LoadLibrary `user32.dll`
sys GDI32=LoadLibrary `GDI32.dll`
bind kernel32
(
GetCommandLine GetCommandLineA ; @0
GetModuleHandle GetModuleHandleA ; @4
ExitProcess ExitProcess ; @4
)
bind user32
(
LoadIcon LoadIconA ; @8
LoadCursor LoadCursorA ; @8
RegisterClass RegisterClassA ; @4
MessageBox MessageBoxA ; @4
CreateWindowEx CreateWindowExA ; @48
ShowWindow ShowWindow ; @8
UpdateWindow UpdateWindow ; @4
GetMessage GetMessageA ; @16
TranslateMessage TranslateMessage ; @4
DispatchMessage DispatchMessageA ; @4
PostQuitMessage PostQuitMessage ; @4
BeginPaint BeginPaint ; @8
EndPaint EndPaint ; @8
GetClientRect GetClientRect ; @8
DrawText DrawTextA ; @20
PostMessage PostMessageA ; @16
DefWindowProc DefWindowProcA ; @16
)
bind GDI32
(
GetStockObject GetStockObject ; @4
)
declare MessageBox(sys hWnd, char* lpText, char* lpCaption,
dword uType) as int at @MessageBox
MessageBox 0,"Hello World", "binding",0
-
Very interesting, thanks.
-
Apparently, this does the same:
extern lib "user32.dll"
! MessageBox "MessageBoxA"
end extern
declare MessageBox(sys hWnd, char* lpText, char* lpCaption,
dword uType) as int at @MessageBox
MessageBox 0,"Hello World", "binding",0
But it seems that with "!" you can also specify the function prototype:
extern lib "user32.dll"
! MessageBox "MessageBoxA"(sys hWnd, char* lpText, char* lpCaption, dword uType) as int
end extern
MessageBox 0,"Hello World", "binding",0
Does "!" accept more variations?