Appel d'une DLL écrite en C# en Delphi
Bonjour a tous,
Comment fait on pour appeler une DLL (et ses fonctions) écrite en C# en delphi?
J'ai essayé le code qui permet d'appeler une DLL C++ en delphi mais ça ne marche pas à savoir :
(PS :ce code marche tres bien pour mes DLL ecrites en c++):
Déclaration du type :
Code:
Tmafonction = procedure(x, y : short); stdcall;
Appel de la fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| procedure Test.CBTestClick(Sender: TObject);
var
mafonction : Tmafonction;
begin
maDll := lectr.ChargeDll('C:\maDll.dll');
if maDll > 0 then
begin
try
MessageDlg('DLL trouvée et chargée', mtInformation, [mbOK], 0);
@mafonction := GetProcAddress(maDll, 'nomdemafonction');
MessageDlg('mafonction = ' + PChar(@mafonction) , mtInformation, [mbOK], 0);
if @mafonctione <> nil then
begin
MessageDlg('mafonction trouvée', mtInformation, [mbOK], 0);
end
else
begin
MessageDlg('mafonction non trouvée', mtInformation, [mbOK], 0);
end;
finally
lectr.LibereDll(maDll);
end;
end;
end; |
Merci de votre aide.