Bonjour,
J'explore l'API SQLite, disponible sous différentes plateformes, dont plein que je ne puis tester...
D'où mon appel au peuple !
J'ai préparé à cet effet une application fmx simplissime :
- une fiche avec un bouton et un mémo, dans laquelle il faut préciser le chemin de la dll adaptée à l'OS, récupérée sur le site : https://sqlite.org/download.html ;
- une unité adhoc.
Après exécution, il suffit d'un copier/coller du mémo dans ce fil de discussion en indiquant l'OS de test, et vous aurez droit à toute ma gratitude !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ScrollBox, FMX.Memo, FMX.Controls.Presentation, FMX.StdCtrls; const DllPath = 'sqlite3.dll'; //***** à changer SVP selon plateforme ***** type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; implementation {$R *.fmx} uses UnitVfsTest; procedure TForm1.Button1Click(Sender: TObject); var Answer: Boolean; Calls: AnsiString; begin Answer := GetSysCalls(Calls); Memo1.Lines.Text := Calls; end; end.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115 unit UnitVfsTest; interface function GetSysCalls(var aString: AnsiString): Boolean; implementation uses System.SysUtils, Unit1; const // Error and Return Codes SQLITE_OK = 0; // Successful result type PSQLiteVFS = ^TSQLiteVFS; // système de fichier virtuel PSystemCall = Pointer; // sur les méthodes systèmes internes au VFS PSQLiteFile = Pointer; TGetSystemCall = function(aVFS: PSQLiteVFS; aName: PAnsiChar): PSystemCall; cdecl; // caractéristiques d'un VFS (Système de Fichier Virtuel) TSQLiteVFS = record // champs de la version 1 (à partir 3.5.0) Version: integer; // VfsVersion = 3 pour la version 3.7.13 de SQLite szOsFile: integer; // taille de la structure SQLite3_File retournée (champs personnels additionnels possibles) mxPathname: integer; // Maximum file pathname length Next: PSQLiteVFS; // interne à SQLite : pas touche ! Name: PAnsiChar; // Name of this virtual file system : doit être unique AppData: Pointer; // Pointer to application-specific data // si Name = nil => utiliser nom temporaire propre au VFS // OutFlags doit refléter SQLITE_OPEN_READONLY si besoin Open: function(aVFS: PSQLiteVFS; aName: PAnsiChar; aFile: PSQLiteFile; aFlags: integer; var aOutFlags: integer): integer; cdecl; Delete: function(aVFS: PSQLiteVFS; aName: PAnsiChar; aSyncDir: LongBool): integer; cdecl; Access: function(aVFS: PSQLiteVFS; aName: PAnsiChar; aFlags: integer; var aOutFlags: integer): integer; cdecl; FullPathName: function(aVFS: PSQLiteVFS; aRelativePath: PAnsiChar; aFullPathSize: integer; aFullPath: PAnsiChar): integer; cdecl; // 4 fonctions liées aux librairies dynamiques DlOpen: function(aVFS: PSQLiteVFS; aFileName: PAnsiChar): Pointer; cdecl; DlError: procedure(aVFS: PSQLiteVFS; aBufferSize: integer; aBuffer: PAnsiChar); cdecl; DlSym: function(aVFS: PSQLiteVFS; aAddress: Pointer; aProcName: PAnsiChar): Pointer; cdecl; // pour Symbol = GetProcAddress DlClose: procedure(aVFS: PSQLiteVFS; aHandle: Pointer); cdecl; // pour initialisation générateur interne Randomness: function(aVFS: PSQLiteVFS; aBufferSize: integer; aBuffer: PAnsiChar): integer; cdecl; Sleep: function(aVFS: PSQLiteVFS; aMicroSeconds: integer): integer; cdecl; CurrentTime: function(aVFS: PSQLiteVFS; var aNow: Double): integer; cdecl; GetLastError: function(aVFS: PSQLiteVFS; aBufferSize: integer; aBuffer: PAnsiChar): integer; cdecl; // champs de la version 2 (à partir 3.7.0 ?) CurrentTime64: function(aVFS: PSQLiteVFS; var aNow: int64): integer; cdecl; // SQLite utilisera CurrentTime si fonction non disponible // champs de la version 3 ; donnent accès pour débogage aux adresses des méthodes systèmes internes au VFS (à partir 3.7.6) // principe étendu à tous les appels à partir de la 3.7.10 SetSystemCall: function(aVFS: PSQLiteVFS; aName: PAnsiChar; aSystemCall: PSystemCall): integer; cdecl; GetSystemCall: TGetSystemCall; NextSystemCall: function(aVFS: PSQLiteVFS; aName: PAnsiChar): PAnsiChar; cdecl; // Additional fields may be added in future releases (i.e. > 3.7.17 and Version > 3) end; function sqlite3_initialize(): integer; cdecl; external DllPath; function sqlite3_shutdown() : integer; cdecl; external DllPath; function sqlite3_vfs_find(aVfsName: PAnsiChar): PSQLiteVFS; cdecl; external DllPath; var GetSystemCall: TGetSystemCall; DefaultVFS: PSQLiteVFS; function HasGotCall(aCall: AnsiString): AnsiString; begin Result := 'appel de la fonction ' + aCall + ' : '; if Assigned(GetSystemCall(DefaultVFS, PAnsiChar(aCall))) then Result := Result + 'OK'#13#10 else Result := Result + 'ko'#13#10; end; function GetSysCalls(var aString: AnsiString): Boolean; begin Result := False; aString := ''; if sqlite3_initialize <> SQLITE_OK then begin aString := 'librairie non initialisee'; Exit; end; DefaultVFS := sqlite3_vfs_find(nil); if not Assigned(DefaultVFS) then begin aString := 'VFS par defaut non renvoyee'; Exit; end else aString := 'VFS par defaut = ' + StrPas(DefaultVFS.Name) + #13#10; if not Assigned(DefaultVFS.GetSystemCall) then begin aString := 'GetSystemCall non renvoye'; Exit; end else GetSystemCall := DefaultVFS.GetSystemCall; aString := aString + HasGotCall('ReadFile'); // sous Windows aString := aString + HasGotCall('WriteFile'); aString := aString + HasGotCall('read'); // sous Unix aString := aString + HasGotCall('write'); aString := aString + HasGotCall('pread'); aString := aString + HasGotCall('pwrite'); aString := aString + HasGotCall('pread64'); aString := aString + HasGotCall('pwrite64'); Result := True; sqlite3_shutdown; end; end.Envoyé par sous Windows 32 Bits
Envoyé par sous Windows 64 Bits
Partager