DLL import from PowerBasic

Just starting out? Need help? Post your questions and find answers here.
Jordi
User
User
Posts: 53
Joined: Sat Apr 26, 2003 10:19 am
Location: Cosmos

DLL import from PowerBasic

Post 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.
kawasaki
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Oct 16, 2003 8:09 pm

Post by kawasaki »

(ignore this post)
Last edited by kawasaki on Mon Sep 15, 2008 10:33 pm, edited 1 time in total.
kawasaki
Enthusiast
Enthusiast
Posts: 182
Joined: Thu Oct 16, 2003 8:09 pm

Post 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
H.Brill
User
User
Posts: 12
Joined: Tue Sep 20, 2005 6:07 am

Post 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
Post Reply