Page 1 of 1

DLL import from PowerBasic

Posted: Mon Sep 15, 2008 7:59 am
by Jordi
My target is to use SQLitening, a PowerBasic DLL for SQLite in a Client/Server pseudo-mode from Fred Meier. (This tool was commented in this forum before).

I have imported the DLL with DLL Importer tool o PB though I don't know how I can see the type of the parameters, once created the import LIB.

The question is how can I translate a call of this:

slConnect ([rsServer String, rlPort Long, rsModChars String]) Long

In the source code of PowerBasic the function is defined like this:
Function slConnect alias "slConnect" (optional byval rsServer as String, _
optional byval rlPort as Long, _
optional byval rsModChars as String) Export as Long

How a string is passed by value in a DLL of PowerBasic, is it a pointer to a null terminated string? A sample of code will be great.

Thanks.

Posted: Mon Sep 15, 2008 6:19 pm
by kawasaki
(ignore this post)

Posted: Mon Sep 15, 2008 8:52 pm
by kawasaki
Hello Jordi,

I may be corrected but I believe it is;

Code: Select all

#SQL_DLL=1

OpenLibrary(#SQL_DLL,"<filename of dll>")

Procedure.l slConnect(Server.s="", Port.l=0, ModChars.s="")
ProcedureReturn CallFunction(#SQL_DLL,"slConnect",Server,Port,ModChars)
Endprocedure

Posted: Tue Sep 23, 2008 5:53 pm
by H.Brill
Hello,
i have made a test.
this works :

Code: Select all

' Power Basic code :
#COMPILE DLL
FUNCTION MyFunc ALIAS "MyFunc"(sArg AS ASCIIZ) EXPORT AS STRING
  MyFunc = "Hello " + sArg
END FUNCTION


; PureBasic code :

If OpenLibrary(0, "J:\Test.dll")
    param1.s = "World"
    String.s = Space(255)
    String = PeekS(CallFunction(0,"MyFunc", @param1))
    Debug(String)
    CloseLibrary(0)
EndIf