const
WM_HOOKMAP = WM_USER + $1000;
//der wichtigste Teil der DLL
function MouseHookProc(Code: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT;
stdcall;
begin
if code = HC_ACTION
then
begin
FileMapObj := OpenFileMapping(FILE_MAP_READ, False,'
HookMapFile');
if FileMapObj <> 0
then
begin
FileMapView := MapViewOfFile(FileMapObj, FILE_MAP_READ, 0, 0, 0);
PostMessage(FileMapView^, WM_HOOKMAP, wParam, lParam);
UnmapViewOfFile(FileMapView);
CloseHandle(FileMapObj);
end;
end;
Result := CallNextHookEx(HookHandle, Code, wParam, lParam);
end;
//und des Programms
FileMapObj: THandle;
FileMapView: ^Integer;
//***************************************
FileMapObj := CreateFileMapping( $FFFFFFFF,
nil, PAGE_READWRITE, 0, SizeOf(Integer), '
HookMapFile');
if FileMapObj = 0
then
raise Exception.Create( '
Error while creating file.');
FileMapView := MapViewOfFile(FileMapObj, FILE_MAP_WRITE, 0, 0, 0);
FileMapView^ := Self.Handle;