手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>程序设计>delphi>列表

插件管理框架 for Delphi(二)

来源:互联网 作者:西部数码 时间:2008-04-09
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!

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
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!