![]() |
Delphi-Version: XE8
E2232 Interface 'x' besitzt keine Interface-Identifikation?
Hänge gerade an einem Interface - Problem und verstehe nicht wieso ich den E2232 Fehler (oder im Alternativfall kein Interface bekomme)!
Folgendes leeres Delphi VCL Projekt (leere Form):
Delphi-Quellcode:
unit Unit2;
interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs; type TForm2 = class(TForm) procedure FormCreate(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form2: TForm2; implementation {$R *.dfm} Const MyIntfAGuid: TGuid = '{23D5751F-8368-4672-ACFC-3BF667F1F544}'; Type IMyIntfA = Interface [MyIntfAGuid] procedure foo; End; TMyClass = Class(TInterfacedObject, IMyIntfA) procedure foo; End; { TMyClass } procedure TMyClass.foo; begin end; procedure TForm2.FormCreate(Sender: TObject); var LMy: TMyClass; LIMyA: IMyIntfA; x: Integer; begin LMy := TMyClass.Create; // so gibts E2232 if Supports(LMy, IMyIntfA) then begin x := 3; end; // so gibts kein Interface if LMy.QueryInterface(MyIntfAGuid, LIMyA) = S_OK then begin x := 3; end; LMy.Free; end; end. Irgendwas mache ich offensichtlich falsch....? |
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Ob´s das ist, weiß ich nicht, aber ich kenne die Deklaration so:
Delphi-Quellcode:
Const
MyIntfAGuid = '{23D5751F-8368-4672-ACFC-3BF667F1F544}'; |
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Zitat:
Delphi-Quellcode:
mit E2010 Inkompatible Typen: 'TGUID' und 'string' rum
if LMy.QueryInterface(MyIntfAGuid, LIMyA) = S_OK then
|
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Zitat:
Delphi-Quellcode:
IMyIntfA = Interface
['{23D5751F-8368-4672-ACFC-3BF667F1F544}'] procedure foo; End; |
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Nein, Du brauchst 2:
Delphi-Quellcode:
Und das Free unterläßt Du besser ;)
const
MyStringIntfAGuid = '{23D5751F-8368-4672-ACFC-3BF667F1F544}'; MyGuidIntfAGuid : TGUID = MyStringIntfAGuid; Type IMyIntfA = Interface(IUnknown) [MyStringIntfAGuid] // Hier den Stringtyp verwenden, wird vom Compiler umgewandelt in Recordtypen procedure foo; End; ... // so gibts ein Interface if LMy.QueryInterface(MyGuidIntfAGuid, LIMyA) = S_OK then |
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Warum eigentlich so kompliziert? Warum nicht einfach so:
Delphi-Quellcode:
type
IMyIntfA = Interface(IUnknown) ['{23D5751F-8368-4672-ACFC-3BF667F1F544}'] procedure foo; end; // so gibts ein Interface if LMy.QueryInterface(IMyIntfA, LIMyA) = S_OK then // oder if Supports(LMy, IMyIntfA, LIMyA) then |
AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?
Danke, wieder was dazugelernt!
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:01 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