Bonjour,
Je voudrai savoir comment appelr une focntion delphi depuis une dll ecrite avec microsoft visual C++.
Lors de mes essaies, bien que les deux debogueurs , celui de borland et de microsoft m'indiquent les mêmes adresses des procédures , lors de l'appel, un acces violation est émis en lieu et place.

code delphi :

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
 
 
 
  TProcHisto=procedure ( Lien : Integer;
                        SsModule: PChar;
                        Message: PChar);
 
  TCallBack = procedure ( idAlarme : integer ; Etat : integer ) ;
 
 
  // Parametres pour l'initialisation
  TParamsInit = record
      Indexconnexion : integer;
      AdresseIP : array [0..15] of char;
      CallBack  : TCallback;
      CallBackHisto : TProcHisto;
  end ;
 
 
procedure Tmonobjet.btConnexionClick(Sender: TObject);
var
  tmpParams : TParamsInit;
begin
     tmpParams.Indexconnexion := 0;
     StrPLCopy(tmpParams.AdresseIP,tbAdresse.Text,length(tbAdresse.Text));
 
     // Mes 2 callbacks
     tmpParams.CallBack := DoCallBAck;
     tmpParams.CallBackHisto := DoCallBackHisto;
 
     // Invocation de la methode d'initialisation de ma dll
     NS_Initialisation ( @tmpparams );
     btEnvoyer.Enabled := True;
 
     test := 0;
end;
Mon code C++

Code C++ : 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
 
// callback 1
typedef void (*TCallback)(int,int);
 
 
// callback 2
typedef void (*TCallBackHisto)(int, char*, char*);
 
struct TParamsInit
{
	int iIndexConnection;
	char AdresseIP[16];     // adresse IP du PABX
	TCallback Callback;
	TCallBackHisto CallBacHisto;
 
};
 
EXPORTATION  DWORD TYPE SYS_InitDLL( struct TParamsInit * Params )
{
 
	// CONSTRUCTION DE L'OBJET
	Lien = new CLienPABX ();
	strncpy ( Lien->AdresseIP , Params->AdresseIP,16);
	Lien->ParamInit = Params;
	Lien->InitLien();
 
	// 
   return 0;
 
...
 
// plus tard l'appel dans l'objet clienPABX 
ParamInit->Callback(0,0);
// Retourne acces violation
}