Bonjour,
Hier je cherchais à transformer du code créer pour Delphi en win32 en code pour Delphi en .Net. Il s'agit d'un bout de l'unité mysql.pas afin d'utiliser l'api mysql.
Le code d'origine est :
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 error_proc = procedure; TMEM_ROOT = record free: PUSED_MEM; used: PUSED_MEM; pre_alloc: PUSED_MEM; min_malloc: longword; block_size: longword; error_handler: error_proc; end; TMYSQL_RES = record row_count: my_ulonglong; field_count, current_field: longword; fields: PMYSQL_FIELDS; data: PMYSQL_DATA; data_cursor: PMYSQL_ROWS; field_alloc: TMEM_ROOT; row: PMYSQL_ROW; current_row: PMYSQL_ROW; lengths: pLongword; handle: PMYSQL; eof: my_bool; end;
Je l'ai traduit par :
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 error_proc = procedure; [StructLayout(LayoutKind.Sequential)] TMEM_ROOT = record free: IntPtr; used: IntPtr; pre_alloc: IntPtr; min_malloc: longword; block_size: longword; [MarshalAs(UnmanagedType.FunctionPtr)] error_handler: error_proc; end; [StructLayout(LayoutKind.Sequential)] TMYSQL_RES = record row_count: my_ulonglong; field_count:longword; current_field: longword; fields: IntPtr; data: IntPtr; data_cursor: IntPtr; [MarshalAs(UnmanagedType.Struct)] field_alloc: TMEM_ROOT; row: IntPtr; current_row: IntPtr; lengths: IntPtr; handle: IntPtr; eof: my_bool; end;
Mais voila ca n'a pas l'air de fonctionner car au moindre appel à marshal.ptrToStructure j'ai une erreur.
Si quelqu'un pouvait m'aider merci.
Partager