Hallo Liebe Community
ich hätte da mal eine Frage bzgl Aufruf einer überladenen Funktion in einer selbst erstellten DLL.
Das funktioniert bei mir nicht so richtig. Vielleich kann mir ja einer von euch helfen. Wo ist mein Denkfehler.
er ruft immer die gleiche Funtion auf und dann (wenn die zweite verwendet werden müsste) kommt eine 'Access violation'
Hier mal meine Dll mit zwei überladenen Funktionen
Delphi-Quelltext
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:
| library DllTest;
uses SysUtils, Classes, Dialogs;
{$R *.res}
function Test(const test1: ShortString; const test2: ShortInt): ShortString; overload; begin Showmessage('Test Version 1'); end;
function Test(const test1: ShortString; test2: ShortString=''; const test3: ShortInt=7): ShortString; overload; begin Showmessage('Test Version 2'); end;
exports Test(const test1: ShortString; const test2: ShortInt), Test(const test1: ShortString; test2: ShortString=''; const test3: ShortInt=7); begin end. |
meine Einbindung in den Code
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| unit uTest;
interface function Test(const test1: ShortString; const test2: ShortInt): ShortString; overload; function Test(const test1: ShortString; test2: ShortString=''; const test3: ShortInt=7): ShortString; overload;
implementation
function Test(const test1: ShortString; const test2: ShortInt): ShortString; overload; external 'DllTest.dll';
function Test(const test1: ShortString; test2: ShortString=''; const test3: ShortInt=7): ShortString; overload; external 'DllTest.dll';
end. |
Rufe ich die Funktion wie folgt auf
Test('Hallo'); => Version 2 sollte und ist aufgerufen worden
Test('Hallo',1); => Version 1 sollte ist aber nicht aufgerufen worden ?????????????
sobald ich diese Version aufrufe => !!!!!ACCESS VIOLATION !!!!!
Test('Hallo','Welt') wie 1
Test('Hallo','Welt',8 ) wie 1
Wäre klasse, wenn mir einer meinen Fehler zeigen könnte.
Vielen Dank im Voraus und an dieses prima Forum
Moderiert von
Christian S.: Code- durch Delphi-Tags ersetzt