我這樣做的方法是在插件中實現一個接口並從主機調用它,例如,
MyApp.Interfaces.pas
uses
Classes;
type
IMyPluginInterface = interface
['{C0436F76-6824-45E7-8819-414AB8F39E19}']
function ConvertToUpperCase(const Value: String): String;
end;
implmentation
end.
插件:
uses
..., MyApp.Interfaces;
type
TMyPluginDemo = class(TJvPlugIn, IMyPluginInterface)
public
function ConvertToUpperCase(const Value: String): String;
...
implmentation
function TMyPluginDemo.ConvertToUpperCase(const Value: String): String;
begin
Result := UpperCase(Value);
end;
...
主持人:
uses
..., MyApp.Interfaces;
...
function TMyHostApp.GetPluginUpperCase(Plugin: TjvPlugin; const Value: String): String;
var
MyPluginInterface: IMyPluginInterface;
begin
if Supports(Plugin, IMyPluginInterface, MyPluginInterface) then
Result := MyPluginInterface.ConvertToUpperCase(Value)
else
raise Exception.Create('Plugin does not support IMyPluginInterface');
end;
希望這有助於。
+1。我正準備以相同的答案作出迴應,但你卻擊敗了我。 – 2010-11-25 12:45:55