📄 dllloader.pas
字号:
unit DLLLoader;
interface
uses
windows, Classes, SysUtils, Forms;
type
TDLLLoader = class(TObject)
private
FHandle: THandle;
FFileName: string;
procedure SetFileName(const Value: string);
protected
function GetApplicationPath: string;
property DLLHandle: THandle read FHandle;
public
constructor Create(DllFileName: string);
destructor destroy(); override;
procedure FreeHandle(); virtual;
property FileName: string read FFileName write SetFileName;
end;
implementation
{ TDLLLoader }//
constructor TDLLLoader.Create(DllFileName: string);
begin
FileName := DLLFileName;
end;
destructor TDLLLoader.destroy;
begin
FreeHandle;
inherited;
end;
procedure TDLLLoader.FreeHandle;
begin
if FHandle <> 0 then
FreeLibrary(FHandle);
end;
function TDLLLoader.GetApplicationPath: string;
begin
result := ExtractFilePath(Application.ExeName);
end;
procedure TDLLLoader.SetFileName(const Value: string);
begin
if FFileName <> Value then
begin
FFileName := Value;
FreeHandle;
FHandle := LoadLibrary(PChar(FFileName));
if FHandle = 0 then
begin
raise Exception.Create('Load Library falut, maybe the ' + FFileName + ' not exists!');
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -