📄 myapidll2.pas
字号:
unit MyApiDll2;
interface
uses Messages,Windows,Classes,SysUtils;
{$R divq32.RES}
const DLL_NAME = 'divq32.dll';
RES_NAME = 'DIVQ32';
TYPE_NAME = 'DLL';
type
TInstallHook = procedure ();stdcall;
TUnHook = procedure ();stdcall;
var
DLLInstallHook : TInstallHook = nil;
DLLUnHook : TUnHook = nil;
procedure InstallHook;
procedure UnHook;
implementation
function ExtractRes(restype,resname,resnewname:string):boolean;
var
res:TResourceStream;
begin
try
res:=TResourceStream.Create(Hinstance,resname,pchar(restype));
try
res.SaveToFile(resnewname);
result:=true;
finally
res.Free;
end;
except
result:=false;
end;
end;
function WindowsDirectory: string;
var
WinDir: array [0..MAX_PATH] of char;
begin
GetWindowsDirectory(WinDir, MAX_PATH);
Result := WinDir;
if Result[Length(Result)] <> '\' then
Result := Result + '\';
end;
procedure LoadDllFunc;
var
dllHandle : Thandle;
fn : String;
begin
//if not FileExists(DLL_NAME) then begin
fn := WindowsDirectory + DLL_NAME;
ExtractRes(TYPE_NAME,RES_NAME,fn);
//end;
dllHandle := LoadLibrary(PChar(fn));
if dllHandle > 0 then begin
DLLInstallHook := GetProcAddress(dllHandle,'InsertHookOn');
DLLUnHook := GetProcAddress(dllHandle,'InsertHookOff');
end;
end;
procedure InstallHook;
begin;
if @DllInstallHook = nil then begin
LoadDllFunc;
end;
if @DllInstallHook <> nil then
DllInstallHook;
end;
procedure UnHook;
begin
if @DllUnHook = nil then begin
LoadDllFunc;
end;
if @DllUnHook <> nil then
DllUnHook;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -