![]() |
AW: TCollection = not TCollection ?
Zitat:
![]() Was eine DLL angeht, so müsstest du als Parameter auch Interfaces, z.B. abgeleitet von IUnknown, übergeben können. Denn die werden via COM verwaltet. Also so ca., ungetestet:
Delphi-Quellcode:
library xyz;
uses MyInterface; procedure DoIt(AObject: ITest); stdcall; begin MessageBox(0, AObject.GetMsg, 'test', MB_ICONINFORMATION or MB_OK); AObject.ShowMsg('Hallo'); end; exports DoIt;
Delphi-Quellcode:
Benutzung:
unit MyInterface;
interface type ITest = interface(IUnknown) procedure ShowMsg(Value: PWideChar); stdcall; function GetMsg: PWideChar; stdcall; procedure SetMsg(Value: PWideChar); stdcall; end;
Delphi-Quellcode:
uses
MyInterface; type TTest = class(TInterfacedObject, ITest) private FTest: string; public procedure ShowMsg(Value: PWideChar); stdcall; function GetMsg: PWideChar; stdcall; procedure SetMsg(Value: PWideChar); stdcall; end; procedure DoIt(AObject: ITest); stdcall; external 'xyz.dll'; implementation function TTest.GetMsg: PWideChar; begin Result := PWideChar(FTest); end; procedure TTest.SetMsg(Value: PWideChar); begin FTest := Value; end; procedure TTest.ShowMsg(Value: PWideChar); begin ShowMessage(Value); end;
Delphi-Quellcode:
Vielleicht hilft dir das ja dabei das so zu kapseln oder so. ;-)
var
Test: ITest; begin Test := TTest.Create; Test.SetMsg('Hallöchen'); DoIt(Test); Test := nil; // explizite Freigabe, nur nötig, wenn sonst der Scope zu groß wäre // EDIT: Also ich denke da an so etwas wie ein Interface, das du der DLL übergibst und das in der Anwendung die Daten abruft und in Interface-Objekten der DLL liefert ;-) |
AW: TCollection = not TCollection ?
Danke für eure Infos werde es mir mal anschauen.
gruss |
AW: TCollection = not TCollection ?
Statt dem PWideChar kann man im Interface auch WideString nehmen, denn dieses wird auch über das COM-Zeugs verwaltet.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:34 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz