Declare or not Declare a prototype ?
Posted: Tue Jun 01, 2021 6:06 pm
How can I prototype a dll function and then use it inside a procedure ? This gives me error:
Code: Select all
If 0 = OpenLibrary(0, "USER32.DLL") : End : EndIf
Prototype.i ProtoMessageBox(Window.i, Body$, Title$, Flags.i = 0)
; 'MsgBox' is a variable with a 'ProtoMessageBox' type
;
MsgBox.ProtoMessageBox = GetFunction(0, "MessageBoxW")
;Declare MsgBox(Window.i, Body$, Title$, Flags.i = 0) ; if uncommented errors: prototype already declared
Procedure.s msg(a.s)
MsgBox(0, "Hello", a) ; errors: MsgBox() is not a function
ProcedureReturn a
EndProcedure
res = msg("World")
Debug res
CloseLibrary(0)