How to return string from callfunction?
Posted: Wed Jul 21, 2004 11:34 am
How do i return a string from a dll function?
Callfunction can't return a string.
Callfunction can't return a string.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
If OpenWindow(0, 0, 0, 320, 240, 0, "") ; just for test purpose
EndIf
If OpenLibrary(0, "USER32.DLL")
ClassName.s = Space(100)
Debug CallFunction(0, "GetClassNameA", WindowID(), @ClassName, 100)
Debug ClassName
CloseLibrary(0)
EndIf
End
Code: Select all
Global Returnvalue$
ProcedureDLL proc1(Name$)
Returnvalue$ = "Hello "+Name$
ProcedureReturn @ReturnValue$
EndProcedure
Code: Select all
#dll = 1
Global ffName.l
res = OpenLibrary(#dll, "testdll.dll")
If res
ffName.l = IsFunction(#dll, "proc1")
Else
MessageBox_(0, "Error", "could not locate dll", 0)
End
EndIf
Procedure.l doesthiswork(name.s)
ProcedureReturn CallFunctionFast(ffName, name)
EndProcedure
MessageBox_(0, doesthiswork("World"), "...", 0)
CloseLibrary(0)
End
Code: Select all
Procedure.l doesthiswork(name.s)
ProcedureReturn CallFunctionFast(ffName, name)
EndProcedure
Code: Select all
Procedure.s doesthiswork(name.s)
ProcedureReturn PeekS(CallFunctionFast(ffName, name))
EndProcedure
Code: Select all
result.s = PeekS(CallFunction(...))