主控程序之插件装载器二
获取插件中的预约接口,调用预约接口中的方法执行插件中某一项功能。
unit Loader;
interface
uses
DLLLoader, uInterface, SysUtils, Classes, windows;
type
TLoader = class(TDLLLoader)
private
FInts: IModelInts;
function GetInts: IModelInts;
public
destructor destroy; override;
property ModelServiceInts: IModelInts read GetInts;
end;
implementation
{ TLoader }
destructor TLoader.destroy;
begin
if FInts <> nil then
FInts := nil;
inherited;
end;
function TLoader.GetInts: IModelInts;
var
InvokeFunc: function: IModelInts;
begin
if FInts = nil then
begin
@InvokeFunc := GetProcAddress(DLLHandle, pchar('GetModelInts'));
if @InvokeFunc <> nil then
begin
FInts := InvokeFunc
end else
raise Exception.Create('插件未提供此方法');
end;
Result := FInts;
end;
end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/archive/2012/02/19/2358363.html