//给你源码,一定要COM+环境:
//主接口A。
unit Unit1;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ActiveX, Mtsobj, Mtx, ComObj, Project1_TLB, StdVcl, Dialogs;
type
TA = class(TMtsAutoObject, IA)
protected
function A1: WideString; safecall;
end;
implementation
uses ComServ, Unit2;
function TA.A1: WideString;
var
Fb: IB;
begin
OleCheck(ObjectContext.CreateInstance(CLASS_B, IID_IB, Fb));
try
ShowMessage(Fb.B1);
finally
Fb := nil;
end;
end;
initialization
TAutoObjectFactory.Create(ComServer, TA, Class_A,
ciMultiInstance, tmApartment);
end.
//子接口B。
unit Unit2;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
ActiveX, Mtsobj, Mtx, ComObj, Project1_TLB, StdVcl;
type
TB = class(TMtsAutoObject, IB)
protected
function B1: WideString; safecall;
end;
implementation
uses ComServ;
function TB.B1: WideString;
begin
Result := 'B';
end;
initialization
TAutoObjectFactory.Create(ComServer, TB, Class_B,
ciMultiInstance, tmApartment);
end.