How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
2008-06-30 00:31
1141 查看
How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
CString str;
CString strTemp; char buf[1024];
char cClassName[1024]; LONG lWndID;
CString strText; ::GetClassName(hwnd,(LPSTR)&cClassName,1024);
strTemp.Format("%s",cClassName);
if("Edit" == strTemp) { LONG lngWndStype; lngWndStype = GetWindowLong(hwnd,GWL_STYLE);
if(lngWndStype & ES_PASSWORD) { //char cTemp;
int intPasswordChar; //发送:EM_GETPASSWORDCHAR 一定要用:SendMessage,用PostMessage返回值不正确
intPasswordChar = SendMessage(hwnd,EM_GETPASSWORDCHAR,0,0);
//不同进程发送:EM_SETPASSWORDCHAR消息,一定用PostMessage,不能用SendMessage,否则无效
PostMessage(hwnd,EM_SETPASSWORDCHAR,0,0);
UpdateWindow(hwnd); //MessageBox(NULL,"Send OK","EM_SETPASSWORDCHAR",MB_OK);
Sleep (100);//停止100毫秒,这点很重要
//::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)strText.GetBuffer(0));
::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)buf);
//不同进程发送:EM_SETPASSWORDCHAR消息,一定用PostMessage,不能用SendMessage,否则无效
PostMessage(hwnd,EM_SETPASSWORDCHAR,intPasswordChar,0);
} else { //::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)strText.GetBuffer(0));
::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)buf); } }
CString str;
CString strTemp; char buf[1024];
char cClassName[1024]; LONG lWndID;
CString strText; ::GetClassName(hwnd,(LPSTR)&cClassName,1024);
strTemp.Format("%s",cClassName);
if("Edit" == strTemp) { LONG lngWndStype; lngWndStype = GetWindowLong(hwnd,GWL_STYLE);
if(lngWndStype & ES_PASSWORD) { //char cTemp;
int intPasswordChar; //发送:EM_GETPASSWORDCHAR 一定要用:SendMessage,用PostMessage返回值不正确
intPasswordChar = SendMessage(hwnd,EM_GETPASSWORDCHAR,0,0);
//不同进程发送:EM_SETPASSWORDCHAR消息,一定用PostMessage,不能用SendMessage,否则无效
PostMessage(hwnd,EM_SETPASSWORDCHAR,0,0);
UpdateWindow(hwnd); //MessageBox(NULL,"Send OK","EM_SETPASSWORDCHAR",MB_OK);
Sleep (100);//停止100毫秒,这点很重要
//::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)strText.GetBuffer(0));
::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)buf);
//不同进程发送:EM_SETPASSWORDCHAR消息,一定用PostMessage,不能用SendMessage,否则无效
PostMessage(hwnd,EM_SETPASSWORDCHAR,intPasswordChar,0);
} else { //::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)strText.GetBuffer(0));
::SendMessage(hwnd,WM_GETTEXT,(WPARAM)1024,(LPARAM)buf); } }
相关文章推荐
- How to get the size of file in C++ - 在C++中如何获取文件的大小
- How to get the file's icon using C++ - 用C++如何获取文件的图标
- How to get random string using C++ - 用 C++ 如何获取随机字符串
- How to change the text color of the selected property sheet tab in Visual C++
- question 002: dev c++ 当中如何调整字体大小?How to get the first program with C++? c++属于什么软件?
- How to get random number within a range using C++ - 如何用C++获取一定范围内的随机数
- How to get a type in C++ when its template argument is the argument
- How to create an XTR file from XML in Delphi XE4 using XML Mapper?(delphi中如何通过xmlmapper创建xtr文件)
- How to get the handle in windows using python
- How to get the nearest parent node given a text node in jQuery?
- Mac环境下mysql初始化密码问题--If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
- How to find a node by its text using the GetNodeByText method
- C#中如何获取其他进程的命令行参数 ( How to get other processes's command line argument )
- Java How to get the PID from a process?
- JS. How to replace html element with another element/text, represented in string?
- How to implement the similar mechanism with Java final in c++?
- How to get the text from any standard object
- C++ How to avoid the enter key when using cin and getline
- A guide to get you building OGRE from source with the default settings in the shortest possible time
- How to get the Values of Selected Row from a Gridview using ASP.NET