I am studying the DLL concept and I am doing some try-and-error's.
Returning a value with String, it works fine.
But apparently not with integers.... (see MyFourthFunction())
Is string the only way to return something from a DLL function call ?
Code: Select all
; My first DLL's => to be saved as "PureBasic.dll"
ProcedureDLL MyFirstFunction()
MessageRequester("Hello","This is a PureBasic DLL !",0)
EndProcedure
ProcedureDLL MySecondFunction()
MessageRequester("Hello","This is my second function, working fine together",0)
EndProcedure
ProcedureDLL.s MyThirdFunction()
ProcedureReturn "returned-some-string"
EndProcedure
ProcedureDLL.i MyFourthFunction()
ProcedureReturn 103
EndProcedure
Code: Select all
EnableExplicit
Define.s string
Define.i integ
If OpenLibrary(0, "PureBasic.dll")
CallFunction(0, "MyFunction")
CallFunction(0, "MySecondFunction")
string.s=PeekS(CallFunction(0,"MyThirdFunction"))
MessageRequester("Returned value:",string)
integ.i=PeekI(CallFunction(0,"MyFourthFunction"))
MessageRequester("Returned value:",Str(integ))
CloseLibrary(0)
EndIf