library PunktDLL; (**************************** * Punkt (Hook-DLL) * * Übersetzt aus c't 5/99 * * von Heino Tiedemann * ****************************) uses SysUtils, Classes, windows, Messages; var MyHook: HHOOK; {Handle auf Die Hook Funktion} {********************* * Hook Funktion * * (Callback) * **********************} Function PunktHook(code: Integer; // hook code HwParam: WPARAM; // virtual-key code HlParam: LPARAM // keystroke-message information ): LRESULT; Stdcall; var Scancode : LPARAM; myWnd : HWND; begin if Code = HC_ACTION then begin if HwParam=VK_DECIMAL then begin scancode := OemKeyscan(Ord('.')) shl 16; //Scanncode vom punkt ermitteln HlParam := hLParam and $FF00FFFF; //durchmaskieren aus einem HlParam := HlParam or scancode; //Komma einen Punkt machen hwParam := 190; MyWnd := GetFocus(); //HensterHandle besorgen if MyWnd=0 then //Etwa eine Dosbox MyWnd := GetForegroundWindow();//dann geht Diese Methode if (hlParam and $8000000) = 0 then postMessage(myWnd,WM_KeyDown,hwParam,hlParam); if (hlParam and $8000000) = $8000000 then postMessage(myWnd,WM_KeyUp,hwParam,hlParam); Result := 1; end else Result := CallNextHookEx(myHook,code,HwParam,HlParam); end else Result := CallNextHookEx(myHook,code,HwParam,HlParam); end; {************************************ * Initialisierung der HOOK-Fuktion * *************************************} procedure DLLInit(hDLL: HINST; install: BOOL); stdcall begin if install = TRUE then //Hook setzen; mit callbackfunktion "PunktHook" myHook := SetWindowsHookEx(WH_KEYBOARD,PunktHook,hDLL,0) else UnhookWindowsHookEx(myHook) end; exports DLLInit index 1; end.