Function Reference


_SQLite_Startup

Loads SQLite3.dll

#include <SQLite.au3>
_SQLite_Startup ( [$sDll_Filename = "" [, $bUTF8ErrorMsg = False [, $iForceLocal = 0 [, $hPrintCallback = $__g_hPrintCallback_SQLite]]]] )

Parameters

$sDll_Filename [optional] DLL filename. Default is "sqlite3.dll" or "sqlite3_x64.dll" in X64 mode.
$bUTF8ErrorMsg [optional] to force ConsoleWrite() to display UTF8 chars
$iForceLocal [optional] 1 = use the defined DLL file. No version checking. Automatic "_x64.dll" in X64 mode.
0 = the DLL will be search in @ScriptDir, @SystemDir, @WindowsDir, and @WorkingDir.
$hPrintCallback [optional] A variable assigned to the user defined function to display a SQLite diagnostic message. Default = __SQLite_ConsoleWrite(). See remarks.

Return Value

Success: the path to the opened DLL file.
Failure: sets the @error flag to non-zero.

Remarks

If #include <SQLite.dll.au3> is included the SQLite version is checked.
The SQLite files can be downloaded from https://www.autoitscript.com/autoit3/pkgmgr/sqlite/SQLite3_version.zip that can be stored in @ScriptDir, @SystemDir, @WindowsDir, or @WorkingDir.

If $bUTF8ErrorMsg is not zero prints UTF8 formated string prints to console.
This allows applications as SciTE to display those characters if configured with output.code.page=65001.
This is the case when running SciTE under a non-english version as Vista(fr).

The $hPrintCallback parameter specifies the name of user-defined callback function. This function will be passed a single parameter which is the message to display. The default callback is $__g_hPrintCallback_SQLite. See that function for an example of how to implement your own callback function.

Related

_SQLite_Shutdown

Example

Example 1

; SQLite.dll version must match

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll = _SQLite_Startup()

If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _
            "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir, @WorkingDir, @LocalAppDataDir\AutoIt v3\SQLite")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 2

; no version reference so file must exist in @SystemDir, @WindowsDir, @ScriptDir or @WorkingDir

#include <MsgBoxConstants.au3>
#include <SQLite.au3>

Local $sSQliteDll
$sSQliteDll = _SQLite_Startup()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!" & @CRLF & @CRLF & _
            "Not FOUND in @SystemDir, @WindowsDir, @ScriptDir or @WorkingDir")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 3

; open SQLite with a specific local file

#include <MsgBoxConstants.au3>
#include <SQLite.au3>

Local $sLocalSQLiteDll = "local SQLite.dll" ; to be change to an existing .dll to have no error

Local $sSQliteDll = _SQLite_Startup($sLocalSQLiteDll, False, 1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "'SQLite3.dll' Can't be Loaded!")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()

Example 4

; Force download from www.autoitscript.com

; #RequireAdmin ; needed if storing in @systemdir is wanted

#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

Local $sSQliteDll = _SQLite_Startup("", False, -1)
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "'SQLite3.dll' Can't be Loaded!")
    Exit -1
EndIf

MsgBox($MB_SYSTEMMODAL, "SQLite3.dll Loaded", $sSQliteDll & " (" & _SQLite_LibVersion() & ")")
ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)
_SQLite_Shutdown()