This QPlugins comes DEMO, probably means that, create two service classes, when the program starts registered the two service classes. Click on the different buttons, use different methods to invoke the service.
The effect interface is as follows
unit Frm_Main; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, QPlugins, qplugins_params, qplugins_base; type TForm_Main = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Memo1: TMemo; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedureButton2Click (Sender: TObject); Procedure Button3Click (Sender: TObject); Private { Private Declarations } public { Public Declarations } End ; // define an interface, the interface methods implemented subclass IQMyServiceExt = interface [ ' {46DD594D-0A3D-49E6 } -BE86-61E653EB3589 ' ] Procedure the SayHello (ASTR: String ); End ; // service extension examples TQMyServiceExt = class (TQInterfacedObject, IQMyServiceExt) Private // implementation of the interface method in Sayhello procedure SayHello(AStr: string = ''); public constructor Create; override; end; // IQMultiInstanceExtension 服务扩展多实例接口 TQMyMultiInstanceExt = class(TQMyServiceExt, IQMultiInstanceExtension) protected function GetInstance(var AResult: IInterface): Boolean; stdcall; end; var Form_Main: TForm_Main; implementation uses qstring; {$R *.dfm} { TQMyServiceExt } // create a constructor TQMyServiceExt. Create ; the begin // calls the Create function ancestor class Inherited ; End ; // implementation of the interface method in Sayhello Procedure TQMyServiceExt.SayHello (ASTR: String ); the begin // output IF ASTR <> '' the then the begin Form_Main.Memo1.Lines.Add (ASTR); End ; Form_Main.Memo1.Lines.Add ( ' expansion interface class named: ' + ClassName); End ; // Create procedure TForm_Main.FormCreate(Sender: TObject); var AService: TQService; AExt: IQMyServiceExt; begin // 注册TQMyServiceExt服务 AService := TQService.Create(NewId, 'Message'); AService.AddExtension(TQMyServiceExt.Create); RegisterServices('Services', [AService]); // 注册TQMyMultiInstanceExt服务 AService := TQService.Create(NewId, 'MultiIntance'); AExt := TQMyMultiInstanceExt.Create; AService.AddExtension (AEXT); RegisterServices ( ' Services ' , [the AService]); End ; { TQMyMultiInstanceExt } // from example service extension function TQMyMultiInstanceExt.GetInstance ( var aResult: IInterface): Boolean; the begin aResult: = TQMyServiceExt. The Create ; the Result: = to true; End ; // button _ transferred directly interfaces Procedure TForm_Main.Button2Click (Sender: TObject); the begin (PluginsManager AS IQMyServiceExt) .SayHello ( '' ); End ; // button press _ modulation path interfaces Procedure TForm_Main.Button1Click (Sender: TObject); var the AService: IQService; the begin the AService: = GetService ( ' / Services / the Message ' ); (the AService AS IQMyServiceExt) .SayHello ( '' ) ; End ; // button extend _ multiple instances Procedure TForm_Main.Button3Click (Sender: TObject); var the AService: IQService; AEXT: IQMyServiceExt; the begin // Get the service instance specified path the AService: GetService = ( ' / services / MultiIntance '); AEXT: = the AService AS IQMyServiceExt; AExt.SayHello (the Format ( ' Interface Address Example: X-% ' , [IntPtr (AEXT)])); End ; End .