获取插件中的预约接口,调用预约接口中的方法执行插件中某一项功能。

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.

相关文章:

  • 2022-02-25
  • 2022-01-10
  • 2021-09-22
  • 2021-07-10
  • 2022-12-23
  • 2021-08-14
  • 2021-06-06
  • 2021-06-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2021-12-21
  • 2022-12-23
  • 2021-11-15
  • 2021-11-21
相关资源
相似解决方案