Windows 2000 下怎么得到密码输入框里的密码?(100分)

  • 主题发起人 主题发起人 devil_li
  • 开始时间 开始时间
D

devil_li

Unregistered / Unconfirmed
GUEST, unregistred user!
Windows 2000 下怎么得到密码输入框里的密码?<br>在Windows 2000 下GetWindowText只能够得到静态的密码,得不到动态输入的密码。
 
搜搜以前的贴子
 
在98,ME下,可以用sendmessage()函數來取,但在2000下就不知道了,如果是采用單向的加密,那就得不到密碼了.
 
首先执行<br>&nbsp; &nbsp;PostMessage(hwnd, EM_SETPASSWORDCHAR, longint(0), 0)<br>然后在Get<br>
 
&gt;&gt;只能够得到静态的密码,得不到动态输入的密码。<br>何谓静态密码,何谓动态密码?
 
PostMessage(hwnd, EM_SETPASSWORDCHAR, longint(0), 0)<br>不行,我试过的,<br>delphi的setPasswordChar源代码有这样一句:<br>&nbsp; Perform(WM_SETTEXT, 0, Longint(Buffer));&lt;----重新设置内容,但如果是外部程序就做不到了。<br>&nbsp; Perform(CM_TEXTCHANGED, 0, 0);<br><br>静态密码是窗体Create以后Edit本来就有的内容,(密码随Exe文件一起编译)<br>动态密码是程序运行时手工输入的密码<br>
 
发送消息后可以的。<br>{-------------------------------------------------------------------------------}<br>{系统的回调过程,在本过程内发送显示/隐藏密码的消息}<br>function EnumChildWindowsProc(hwnd: Integer; lparam: Longint): Boolean; stdcall;<br>var<br>&nbsp; buffer: array[0..255] of Char;<br>begin<br>&nbsp; GetClassName(hwnd, buffer, 256);<br>//if StrPas(Buffer) = 'TEdit' then &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//找TEdit控件<br>&nbsp; begin<br>&nbsp; &nbsp; if lparam = 0 then<br>&nbsp; &nbsp; &nbsp; PostMessage(hwnd, EM_SETPASSWORDCHAR, longint(0), 0)<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp; PostMessage(hwnd, EM_SETPASSWORDCHAR, longint('*'), 0);<br><br>&nbsp; &nbsp; InvalidateRgn(hwnd, 0, True);<br>&nbsp; &nbsp; Result := True; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //终止循环<br>&nbsp; end;<br>end;<br><br>{-------------------------------------------------------------------------------}<br>{显示/隐藏所有窗体密码,本部分枚举所有窗体}<br>procedure ShowAll(lparam: Integer);<br>var<br>&nbsp; Window_Handle, Hand: Integer;<br>begin<br>&nbsp; Window_Handle := GetWindow(Application.Handle, GW_HWNDFIRST);<br>&nbsp; while Window_Handle &lt;&gt; 0 do<br>&nbsp; begin<br>&nbsp; &nbsp; if Window_Handle &lt;&gt; 0 then<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; EnumChildWindows(Window_Handle, @EnumChildWindowsProc, lparam);<br>&nbsp; &nbsp; end;<br>&nbsp; &nbsp; Window_Handle := GetWindow(Window_Handle, GW_HWNDNEXT);<br>&nbsp; end;<br>end;<br><br>{-------------------------------------------------------------------------------}<br>{响应按键}<br>procedure TFrm_ShowPass.sbtn_ShowPassClick(Sender: TObject);<br>begin<br>&nbsp; ShowAll(0);<br>end;<br><br>procedure TFrm_ShowPass.sbtn_hidePassClick(Sender: TObject);<br>begin<br>&nbsp; ShowAll(1);<br>end;
 
原来必须用PostMessage,不能用SendMessage,不过这样就不能同步了。<br>当我要读取Edit中的内容而又不破坏PasswordChar时就不好办了,<br>现在我我是这样用的:<br>&nbsp; &nbsp; PostMessage(hwnd, EM_SETPASSWORDCHAR, 0, 0);<br>&nbsp; &nbsp; Sleep(100);<br>&nbsp; &nbsp; SendMessage(hwnd, WM_GETTEXT, Length(Result) + 1, Longint(Pointer(Result)));<br>&nbsp; &nbsp; PostMessage(hwnd, EM_SETPASSWORDCHAR, PassChar, 0);<br>呵呵,不过这个方法肯定不大好。<br>不知道有没有更好的方法?<br><br>给分了。。。<br>
 
后退
顶部