Bonjour,
Je teste actuellement la création et l'utilisation de dll avec Delphi 7.
Je me suis inspiré de ce tuto.
J'ai créé le projet suivant :
Cela me crée une dll.
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 library MaLibrary; uses SysUtils, Classes, StrUtils; {$R *.res} function Factorielle(n: Integer): Integer; stdcall; export; begin if (n = 0) then Result := 1 else Result := n * Factorielle(n-1); end; function StrToUpper(const str: string): string; stdcall; export; begin Result := UpperCase(str); end; exports Factorielle, StrToUpper; begin end.
J'ai ensuite un projet de test dans lequel je place ma dll.
L'unité principale fait simplement ceci :
Au lancement de cette application, j'ai l'erreur "Opération de pointer incorrecte".
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 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); private { Déclarations privées } public { Déclarations publiques } end; var Form1: TForm1; function Factorielle(n: Integer): Integer; stdcall; external 'MaLibrary.dll'; function StrToUpper(const str: string): string; stdcall; external 'MaLibrary.dll'; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin Caption := StrToUpper(Caption); end; end.
Pouvez-vous m'aider à corriger ce qui ne va pas, je ne trouve pas.
Partager