1 前言
2 插件框架(untDllManager)
2.2 实现代码
unit untDllManager;
interface
uses
Windows, Classes, SysUtils, Forms;
type
EDllError = Class(Exception);
TDllClass = Class of TDll;
TDll = Class;
TDllEvent = procedure(Sender: TObject; ADll: TDll) of Object;
{ TDllManager
o 提供对 Dll 的管理功能;
o Add 时自动创建 TDll 对象,但不尝试装载;
o Delete 时自动销毁 TDll 对象;
}
TDllManager = Class(TList)
private
FLock: TRTLCriticalSection;
FDllClass: TDllClass;
FOnDllLoad: TDllEvent;
FOnDllBeforeUnLoaded: TDllEvent;
function GetDlls(const Index: Integer): TDll;
function GetDllsByName(const FileName: String): TDll;
protected
procedure Notify(Ptr: Pointer; Action: TListNotification); override;
public
constructor Create;
destructor Destroy; override;
function Add(const FileName: String): Integer; overload;
function IndexOf(const FileName: String): Integer; overload;
function Remove(const FileName: String): Integer; overload;
procedure Lock;
procedure UnLock;
property DllClass: TDllClass read FDllClass write FDllClass;
property Dlls[const Index: Integer]: TDll read GetDlls; default;
property DllsByName[const FileName: String]: TDll read GetDllsByName;
property OnDllLoaded: TDllEvent read FOnDllLoad write FOnDllLoad;
property OnDllBeforeUnLoaded: TDllEvent read FOnDllBeforeUnLoaded write FOnDllBeforeUnLoaded;
end;
{ TDll
o 代表一个 Dll, Windows.HModule
o 销毁时自动在 Owner 中删除自身;
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




