Nur so fürs Protokoll, versuche es mal so
Delphi-Quellcode:
program dp_183554;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
type
IMyInterface =
interface
['
{88DDD9A5-F4BC-47B9-9240-31B1C986F230}']
procedure doSomething( );
end;
TMyClass =
class( TInterfacedObject, IMyInterface )
public
constructor Create( );
procedure doSomething( );
end;
procedure justSupportsThings( );
var
myObject: TObject;
myIntf: IMyInterface;
castSuccessful: Boolean;
begin
myObject := TMyClass.Create( );
castSuccessful := Supports( myObject, IMyInterface, myIntf );
if castSuccessful
then
myIntf.doSomething( );
end;
constructor TMyClass.Create( );
begin
inherited;
// Schwachfug
// _AddRef(); // Damit mich das Supports(..) nicht abräumt
end;
procedure TMyClass.doSomething;
begin
// nop
end;
begin
try
justSupportsThings( );
except
on E:
Exception do
Writeln( E.ClassName, '
: ', E.
Message );
end;
readln;
end.
Kaum macht man's richtig - schon funktioniert's
Zertifikat: Sir Rufo (Fingerprint: ea 0a 4c 14 0d b6 3a a4 c1 c5 b9
dc 90 9d f0 e9 de 13 da 60)