Ja, aber die Implementation der ersten Interface ... war schon "vorhanden".
Die vorhandene Klasse die eine Interface implementiert sieht so aus:
Delphi-Quellcode:
TSB_API = class(TOleServer) // hier TOleServer!
private
...
FIntf: ISB_API;
function GetDefaultInterface: ISB_API;
protected
procedure InitServerData; override;
procedure InvokeEvent(DispID: TDispID; var Params: TVariantArray); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Connect; override;
procedure ConnectTo(svrIntf: ISB_API);
procedure Disconnect; override;
procedure Init(const p_bstrIN: WideString; out p_pbstrOUT: WideString; out p_plRetVal: Integer);
...
end;
...
procedure Register;
resourcestring
dtlServerPage = '(none)';
dtlOcxPage = '(none)';
implementation
uses ComObj;
class function CoSB_API.Create: ISB_API;
begin
Result := CreateComObject(CLASS_SB_API) as ISB_API;
end;
class function CoSB_API.CreateRemote(const MachineName: string): ISB_API;
begin
Result := CreateRemoteComObject(MachineName, CLASS_SB_API) as ISB_API;
end;
...
procedure TSB_API.Connect;
var
punk: IUnknown;
begin
if FIntf = nil then
begin
punk := GetServer;
ConnectEvents(punk);
Fintf:= punk as ISB_API;
end;
end;
function TSB_API.GetDefaultInterface: ISB_API;
begin
if FIntf = nil then
Connect;
Assert(FIntf <> nil, 'DefaultInterface ist NULL. Die Komponente ist nicht mit dem Server verbunden. Sie müssen vor dieser Operation ''Connect'' oder ''ConnectTo'' aufrufen');
Result := FIntf;
end;
procedure TSB_API.Init(const p_bstrIN: WideString; out p_pbstrOUT: WideString;
out p_plRetVal: Integer);
begin
DefaultInterface.Init(p_bstrIN, p_pbstrOUT, p_plRetVal); //hier klappt es!
end;
...
Meine Klasse für die neue Interface sieht so aus (habe ein
COM Object erstellt):
Delphi-Quellcode:
type
TSB_SIS = class(TAutoObject, ISB_SIS) // hier TAutoObject!
private
isb: ISB_SIS;
protected
public
constructor Create;
destructor Destroy; override;
procedure Advise4SIS(const p_bstrIN: WideString; out p_pbstrOUT: WideString;
out p_plRetVal: Integer); safecall;
...
end;
...
implementation
uses ComServ;
constructor TSB_SIS.Create;
begin
isb := CoISB_SIS.Create;
end;
destructor TSB_SIS.Destroy;
begin
inherited;
end;
procedure TSB_SIS.Advise4SIS(const p_bstrIN: WideString;
out p_pbstrOUT: WideString; out p_plRetVal: Integer);
begin
isb.Advise(p_bstrIN, p_pbstrOUT, RetVal); //hier klappt es nicht!
end;
...
... es klappt leider nicht!