Call a function in a shared library: Difference between revisions

No edit summary
(→‎{{header|PureBasic}}: added Prototype)
Line 338:
 
=={{header|PureBasic}}==
Older PureBasic versions normally relied on CallFunction() and CallFunctionFast()
<lang Purebasic>
if OpenLibrary(0, "USER32.DLL")
*MessageBox = GetFunction(0, "MessageBoxA")
CallFunctionFast(*MessageBox, 0, "Body", "Title", 0)
*MessageBox = GetFunction(0, "MessageBoxA")
CloseLibrary(0)
endif</lang>
CallFunctionFast(*MessageBox, 0, "Body", "Title", 0)
Since versions 4 the recommended way is via the usage of Prototypes even if the old system still is supported.
<lang PureBasic>Prototype.l ProtoMessageBoxW(Window.l, Body.p-unicode, Title.p-unicode, Flags.l = 0)
CloseLibrary(0)
 
</lang>
If OpenLibrary(0, "User32.dll")
MsgBox.ProtoMessageBoxW = GetFunction(0, "MessageBoxW")
MsgBox(0, "Hello", "World")
CloseLibrary(0)
EndIf</lang>
 
=={{header|Python}}==
Anonymous user