AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language E2232 Interface 'x' besitzt keine Interface-Identifikation?

E2232 Interface 'x' besitzt keine Interface-Identifikation?

Ein Thema von Whookie · begonnen am 20. Jul 2015 · letzter Beitrag vom 20. Jul 2015
Antwort Antwort
Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#1

E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 12:40
Delphi-Version: XE8
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....?
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat
Benutzerbild von stahli
stahli

Registriert seit: 26. Nov 2003
Ort: Halle/Saale
4.336 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 12:54
Ob´s das ist, weiß ich nicht, aber ich kenne die Deklaration so:

Delphi-Quellcode:
Const
   MyIntfAGuid = '{23D5751F-8368-4672-ACFC-3BF667F1F544}';
Stahli
http://www.StahliSoft.de
---
"Jetzt muss ich seh´n, dass ich kein Denkfehler mach...!?" Dittsche (2004)
  Mit Zitat antworten Zitat
Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#3

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 12:58
Ob´s das ist, weiß ich nicht, aber ich kenne die Deklaration so:

Delphi-Quellcode:
Const
   MyIntfAGuid = '{23D5751F-8368-4672-ACFC-3BF667F1F544}';
Hatte ich auch schon probiert aber dann mäkelt der Compiler bei:

if LMy.QueryInterface(MyIntfAGuid, LIMyA) = S_OK then mit E2010 Inkompatible Typen: 'TGUID' und 'string' rum
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat
Bambini
(Gast)

n/a Beiträge
 
#4

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 13:01
Irgendwas mache ich offensichtlich falsch....?
Vermutlich kannst du die GUID für das Interface nur so angeben:

Delphi-Quellcode:
  IMyIntfA = Interface
    ['{23D5751F-8368-4672-ACFC-3BF667F1F544}']
    procedure foo;
  End;
  Mit Zitat antworten Zitat
Benutzerbild von Union
Union

Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.487 Beiträge
 
Delphi 7 Enterprise
 
#5

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 13:23
Nein, Du brauchst 2:

Delphi-Quellcode:
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
Und das Free unterläßt Du besser
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all

Geändert von Union (20. Jul 2015 um 13:30 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke
Online

Registriert seit: 10. Jun 2003
Ort: Berlin
9.326 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 14:03
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
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
Whookie

Registriert seit: 3. Mai 2006
Ort: Graz
441 Beiträge
 
Delphi 10.3 Rio
 
#7

AW: E2232 Interface 'x' besitzt keine Interface-Identifikation?

  Alt 20. Jul 2015, 16:18
Danke, wieder was dazugelernt!
Whookie

Software isn't released ... it is allowed to escape!
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 23:04 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz