Question Calling PowerBasic/SQLite DLL?

littlebigman

Well-known member
Joined
Jan 5, 2010
Messages
75
Programming Experience
Beginner
Hello

I'd like to give SQLitening a shot and call their DLL from a VB.Net application to see how well it performs to work with a remote SQLite server.

I don't know enough about VB.Net yet to know how to call a DLL. Here are the SQLitening include files:


And more information about SQLitening from their documentation:

All DLL's are written in PowerBASIC and use the SDECL (aka STDCALL) convention for parameter passing. SDECL specifies that the declared procedure uses the "Standard Calling Convention" as defined by Microsoft. When calling an SDECL procedure, parameters are passed on the stack from right to left and the stackl is automatically cleaned before execution returns to the calling code.

PowerBASIC allocates strings using the Win32 OLE string engine. This allows you to pass strings from your program to DLLs, or API calls that support OLE strings.

SQLitening comes with three different API's as follows:

- Basic: SQLitening.Dll + SQLitening.Inc
Always try to use the Basic API. If you language supports passing OLE strings both ByVal and ByRef then you should be able to use the Basic API. OLE strings are allocated using the Win32 OLE string engine. There are some routines in the Basic API that will probably only work with PowerBASIC. slSelAry is one that passes an array and therefore may only work in PowerBASIC. You may need to modify the include file (SQLitening.Inc) to support your language.

- Special: SQLiteningS.Dll + SQLiteningS.Inc
If your language supports OLE string passing but only ByRef (Visual Basic) then the Special API will probable work for you. The language must also support optional parameter passing. The slSelAry is not available in this API. You will need to modify the include file (SQLiteningS.Inc) to support your language This DLL is a front-end to the Basic API.

- Universal: SQLiteningU.Dll + SQLiteningU.Inc
If your language does not support OLE strings then the Special API will probable work for you. This API will work for any language that can call a standard Dll. The parameter passing is patterned after the Windows API. The slSelAry is not available in this API. You will need to modify the include file (SQLiteningU.Inc) to support your language This DLL is a front-end to the Basic API. Documentation about parameter passing is located in the include file.

For those of you well-versed in calling DLL's from VB.Net, would you it'd be easy to use SQLitening from VB.Net?

Thank you.
 
You don't call DLLs. You call the functions in DLLs. If you want to call functions exported from an unmanaged (i.e. non-.NET) DLL then the mechanism is called Platform Invoke, or PInvoke for short. You declare a proxy function with a matching signature in your VB code and tell the system where to find the real function. You then call your proxy function just like you would any other method, but the system maps the call to the external function. This is the same mechanism used to invoke the Windows API.

You should generally put the unmanaged DLL in the system32 folder if it's a shared library, or else in the same folder as your EXE otherwise. In code, you can use the Declare keyword to denote a proxy function. That's a holdover from VB6 though. It's better to use the .NET standard of applying the DllImport attribute to your proxy function.

You can read more about PInvoke and the DllImport attribute at MSDN and on the web.
 
Back
Top