Bonjour*!!
J’ai écris une DLL en C qui export quelques fonctions qui prennent comme
paramètre un pointeur sur une structure ( struct *).
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
PEXPORT int  SommeFunc( struct * PStr)*;
La structure en elle-même comporte deux pointeurs sur fonctions (pour le Callback)
Jusque la tout va bien et les test vont bien ( en C et en Delphi ).
Voici l’interpretation en Delphi du fichier .h
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
 
const
  bsLib2 = 'wgetfire2.dll' ;
type
  bsSplitAll = function (total : Double; chunk : integer )	: Integer ; cdecl;
  bsProgress = function (ptr: Pointer ;dltotal, dlNow, dlspeed : Double ; Handle: Integer): Integer ; cdecl;
 
(* typedef struct _bsHttpFile
{
	bStr		URL		;	// url
	UInt        Port	;	// port  80
	bStr		User	;
	bStr		Pass
    bStr		Local	;	// local file name 
    UInt        threadCount;// num of threads (not used )	
	UInt		Chunk	;	// chunk for splitting
    //Callback Functions      
    bsSplitAll	Spt		;	// splitting files 
	bsProgress  WPrg	; 	// my progress to manage Progress Bars
} bsHttpFile, *PbsHttpFile; *)
  PbsHttpFile = ^TbsHttpFile ;
  TbsHttpFile = record
    URL   : PChar ;
    Port  : Word  ;
    User  : PChar ;
    Pass  : PChar ;
    Local : PChar ;
    Threads: Word ;
    Chunk : Longint ;
    Spt   : bsSplitAll;
    WPrg  : bsProgress;
  end;
// fonctions 
function bsGetFileFromHttp6 (const htp: PbsHttpFile ) : integer; cdecl; external bsLib2 name 'bsGetFileFromHttp6';
function bsGetFileFromHttp8 (const htp: PbsHttpFile ) : integer; cdecl; external bsLib2;
Le problème se manifeste lorsque je crée un composant qui encapsuler cette DLL au nivaux
du <B>passage d’un événement dans le Callback</B> { récupérer les valeurs du Callback dans l’événement déclanché }
Voici le code pour plus de clarté ..
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
 
 
interface
  TDownloadProgress = procedure ( Sender: TObject; dltotal, dlNow: Integer ;
          dlspeed: Double; Handle: Integer) of object;
 
 
  TbsCurlGrabber = class(TComponent)
  private
    //... Others Fields 
	FOnDwProgress: TDownloadProgress;
	//...
  protected
    procedure TriggerDwProgress(Sender: TObject; dltotal, dlNow: Integer ;
          dlspeed: Double; Handle: Integer);
	// .....
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    function bsGetFileFromHttp: Integer;
  published
    property OnDwProgress: TDownloadProgress read FOnDwProgress write  SetOnDwProgress;
	// ...
  end;
 
implementation
function DoProgress(ptr: Pointer; dltotal, dlNow, dlspeed: Double; Handle:
    Integer): Integer; cdecl;
begin
//   with TbsCurlGrabber(ptr) do
//   begin
//     {TriggerDownloadProgress(TObject(ptr),LongInt(Round(dltotal)),LongInt(Round(dlNow)),dlspeed,Handle);}
//     TriggerDwProgress(TObject(ptr),LongInt(Round(dltotal)),LongInt(Round(dlNow)),dlspeed,Handle);
//   end;    // with // ne marche pas 
  with TbsCurlGrabber(ptr) do
  begin
    if (@FOnDwProgress <> nil) then begin // if Assigned(FOnDwProgress) aussi ne marche pas 
      FOnDwProgress(TbsCurlGrabber(ptr),LongInt(Round(dltotal)), LongInt(Round(dlNow)),dlspeed,Handle);
      ShowMessage('Tester for ME');
    end;
  end;    // with et ne marche pas aussi 
  result := 0; 
end;
 
function TbsCurlGrabber.bsGetFileFromHttp: Integer;
begin
 
  with fbsHttpFile do
  begin
    URL   :=  PChar(FURL) ;
    Port  :=  FPort ;
    Chunk :=  FChunk ;
    Local :=  PChar(FOutFile) ;
    Spt := nil ;
    WPrg := @DoProgress ;
  end;    // with
 
  case FThreads of    //
    thD6 : Result := bsGetFileFromHttp6 (@fbsHttpFile);
    thD8 : Result := bsGetFileFromHttp8 (@fbsHttpFile);  
  else
    Result := 0
  end;
enfin j'ai essayer tout les moyens ..
déclanche l'evenement via le procedure
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
    procedure TriggerDwProgress(Sender: TObject; dltotal, dlNow: Integer ;
          dlspeed: Double; Handle: Integer);
puis passer cetter deniere dans le Callback mais rien ne marche ..
Sincerement je ne sais quoi faire
MERCI POUR VOTRE AIDE MESSIEURS