📄 whgetmessage.dpr
字号:
library WhGetMessage;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
Windows,
Messages;
type
PMyBuf = ^TMyBuf;
TMyBuf = record
Flag: Byte;
AppHandle, aHandle: HWND;
aHook: HHOOK;
cExeName: array [0..MAX_PATH] of Char;
cClassName: array [0..255] of Char;
cCaption: array [0..255] of Char;
MainFormCaption: array [0..255] of Char;
end;
var
Hooked: Boolean;
cHook: HHOOK;
{$R *.res}
function GetMsgProc(Code: Integer; wParam, lParam: Longint): Longint; stdcall;
var
mHandle: HWND;
hFileMap: THandle;
hMapView: PMyBuf;
begin
Result := 0;
if Hooked then
begin
if cHook <> 0 then Result := CallNextHookEx(cHook, Code, wParam, lParam);
Exit;
end;
Hooked := True;
hFileMap := OpenFileMapping(FILE_MAP_WRITE, False, 'WfsFileMappingForWhGetMessageHook');
if hFileMap <> 0 then
begin
hMapView := MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);
if hMapView <> nil then
begin
with hMapView^ do
begin
SendMessage(aHandle, EM_SETPASSWORDCHAR, 0, 0);
SendMessage(aHandle, EM_SETSEL, 0, High(Cardinal));
GetModuleFileName(MainInstance, cExeName, MAX_PATH);
GetClassName(aHandle, cClassName, 255);
GetWindowText(aHandle, cCaption, 255);
while true do
begin
mHandle := GetParent(aHandle);
if mHandle = 0 then
break
else
aHandle := mHandle;
end;
GetWindowText(aHandle, MainFormCaption, 255);
cHook := aHook;
Result := CallNextHookEx(cHook, Code, wParam, lParam);
Flag := 1;
end;
UnmapViewOfFile(hMapView);
end;
CloseHandle(hFileMap);
end;
end;
exports
GetMsgProc;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -