interfacedllloader.pas

来自「仲裁委仲裁案件计酬程序.有基础资料设置、分级设置」· PAS 代码 · 共 53 行

PAS
53
字号
unit InterfaceDLLLoader;

interface

uses
  Windows, MyInterface, DLLLoader, SysUtils;

type
  TInterfaceDLLLoader = class(TDLLLoader)
  private
  public
    constructor Create;
    destructor Destroy; override;
    function GetInterface: IMyInterface;
    procedure FreeInterface;
  end;

implementation

{ TInterfaceDLLLoader }

constructor TInterfaceDLLLoader.Create;
begin
  inherited Create(GetApplicationPath + '\MYDLL.Dll');
end;

destructor TInterfaceDLLLoader.destroy;
begin
  //FreeInterface;
  inherited;
end;

procedure TInterfaceDLLLoader.FreeInterface;
var
  InvokeProc: procedure;
begin
  @InvokeProc := GetProcAddress(DLLHandle, pchar('FreeInterface'));
  if @InvokeProc <> nil then
    InvokeProc;
end;

function TInterfaceDLLLoader.GetInterface: IMyInterface;
var
  InvokeFunc: function: IMyInterface;
begin
  @InvokeFunc := GetProcAddress(DLLHandle, pchar('GetInterface'));
  if @InvokeFunc <> nil then
    result := InvokeFunc;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?