Einzelnen Beitrag anzeigen

Benutzerbild von Neutral General
Neutral General

Registriert seit: 16. Jan 2004
Ort: Bendorf
5.219 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#3

AW: DLL - Objekte austauschen

  Alt 19. Dez 2018, 14:25
Ich könnte TFooBar ableiten, aber sofern ich jetzt nicht irgendwas verpasse bringt mir das nicht wirklich was.
Der Konstruktor des Bibliotheks-Objekts will ja trotzdem ein TFooBar und kein Interface.
Selbst wenn ich ein
Delphi-Quellcode:
//
TMeinFooBar = class(TFooBar, IFoobarKapselung)
hätte, bräuchte ich ja trotzdem eine Objektinstanz um sie der Bibliothek zu übergeben:

Delphi-Quellcode:
// Anwendung
var
  foobar: TFooBar;
  kapselung: IFoobarKapselung;
begin
  foobar := TFoobar.Create;
  kapselung := TFoobarKapselung.Create(foobar);

  DoDLLStuff(kapselung);

// DLL

procedure DoDLLStuff(const fooBar: IFoobarKapselung);
var bib: TBibliotheksObject;
begin
  bib := TBibliotheksObject.Create(TFooBar(foobar._Instance)); // Ich kann ja "foobar" nicht übergeben.. egal ob dahinter ein TFoobar oder ein TMeinFoobar = class(TFoobar) hängt
end;

// Bibliothek:

TBibliotheksObject = class
public
  constructor Create(AFoobar: TFoobar);
end;
Oder habe ich dich falsch verstanden?
Michael
"Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination,
but because their imagination reveals worlds that others cannot see."
  Mit Zitat antworten Zitat