﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-                                                    雅了可爱</title><link>http://www.cppblog.com/hxg/</link><description>                                                    沉淀</description><language>zh-cn</language><lastBuildDate>Wed, 15 Apr 2026 03:50:49 GMT</lastBuildDate><pubDate>Wed, 15 Apr 2026 03:50:49 GMT</pubDate><ttl>60</ttl><item><title>重新认识GetWindowText</title><link>http://www.cppblog.com/hxg/archive/2014/12/30/209351.html</link><dc:creator>ylka</dc:creator><author>ylka</author><pubDate>Tue, 30 Dec 2014 14:02:00 GMT</pubDate><guid>http://www.cppblog.com/hxg/archive/2014/12/30/209351.html</guid><wfw:comment>http://www.cppblog.com/hxg/comments/209351.html</wfw:comment><comments>http://www.cppblog.com/hxg/archive/2014/12/30/209351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hxg/comments/commentRss/209351.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hxg/services/trackbacks/209351.html</trackback:ping><description><![CDATA[<div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><span style="font-family: 'Comic Sans MS'; font-size: 12pt; line-height: 21px;">&nbsp; &nbsp;</span><span style="font-family: verdana, 'courier new'; font-size: 14px; line-height: 21px;">&nbsp; &nbsp;</span><span style="font-size: 12pt; text-align: -webkit-auto; font-family: 'Comic Sans MS';">在实际工作中遇到这样的问题：模块注入到某目标进程获取某个窗口标题的时候失败。工具探测：spy++无法获取窗口标题，其它工具（勇芳窗口管理器、自己写的demo）却可以获取到。</span></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><span style="font-size: 12pt;"><br /></span><span style="font-size: 12pt; font-family: 'Comic Sans MS';">一般来说，获取窗口标题的方法有两个：</span></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><div><span style="font-size: 12pt; font-family: 'Comic Sans MS';">1）GetWindowText（hWnd）</span></div><div><span style="font-size: 12pt; font-family: 'Comic Sans MS';">2）SendMessage（hWnd，WM_GETTEXT）</span></div></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><span style="font-size: 12pt;"><br /></span><span style="font-size: 12pt; font-family: 'Comic Sans MS';">另外，根据<u>http://blogs.msdn.com/b/oldnewthing/archive/2003/08/21/54675.aspx</u>知道下面2点：</span></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><div><span style="font-size: 12pt; font-family: 'Comic Sans MS';">1）如果是获取本进程窗口标题的话，GetWindowText是发送WM_GETTEXT消息来拿标题内容的，这和主动调用SendMessage发送WM_GETTEXT没区别。</span></div><div><span style="font-size: 12pt; font-family: 'Comic Sans MS';">2）如果是获取其它进程窗口标题的话，GetWindowText是直接从窗口内部相关的数据结构中拿到标题内容的，不发送WM_GETTEXT消息。</span></div></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"></div><div style="font-family: 新宋体; line-height: normal; orphans: 2; text-align: -webkit-auto; widows: 2; font-size: medium;"><span style="font-size: 12pt;"><br /></span>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 12pt; font-family: 'Comic Sans MS';">所以，当窗口标题只能从窗口内部相关的数据结构中拿到，而我们又是获取本进程的窗口标题的时候，通过GetWindowText和SendMessage都是无法获取的。这时候要使用一个新的API：</span><span style="font-size: 12pt; font-family: 'Comic Sans MS';"><strong>InternalGetWindowText</strong>，it obtains the window text directly from the window structure associated with the specified window's handle and then always provides the text as a unicode string。（比较旧的sdk中是没有的）。</span></div><img src ="http://www.cppblog.com/hxg/aggbug/209351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hxg/" target="_blank">ylka</a> 2014-12-30 22:02 <a href="http://www.cppblog.com/hxg/archive/2014/12/30/209351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>非MFC预定义好的消息在MFC程序中如何处理？</title><link>http://www.cppblog.com/hxg/archive/2012/04/24/172551.html</link><dc:creator>ylka</dc:creator><author>ylka</author><pubDate>Tue, 24 Apr 2012 02:09:00 GMT</pubDate><guid>http://www.cppblog.com/hxg/archive/2012/04/24/172551.html</guid><wfw:comment>http://www.cppblog.com/hxg/comments/172551.html</wfw:comment><comments>http://www.cppblog.com/hxg/archive/2012/04/24/172551.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hxg/comments/commentRss/172551.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hxg/services/trackbacks/172551.html</trackback:ping><description><![CDATA[下面以添加查找对话框FINDMSGSTRING消息的处理函数为例：<br />&nbsp;&nbsp; 打开查找对话框后，当用户单击&#8220;查找下一个&#8221;或者其他按钮时，对话框会向父窗口发送FINDMSGSTRING消息，这不是MFC中预先定义好的消息，故不能通过ClassWizard添加消息处理函数，必须手动添加。添加过程如下：<br />&nbsp;&nbsp; 1.先在CDemoView.h文件的头部&#8220;class CDemoView&#8221;语句前添加如下代码，将FINDMSGSTRING消息注册为WM_FINDREPLACE自定义消息：<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const WM_FINDREPLACE = ::RegisterWindowMessage(FINDMSGSTRING);<br />&nbsp;&nbsp; 2.同时在CDemoView.h文件的CDemoView类的声明中找到&#8220;DECLARE_MESSAGE_MAP()&#8221;语句，在这个语句前一行添加如下语句作为消息处理函数的声明：<br />&nbsp;&nbsp; &nbsp;&nbsp; afx_msg LONG OnFindReplace(WPARAM wParam, LPARAM lParam);<br />&nbsp;&nbsp; 3.接着在CDemoView.cpp文件的头部找到&#8220;END_MESSAGE_MAP()&#8221;语句，在这个语句的前一行添加如下语句绑定消息WM_FINDREPLACE和消息处理函数OnFineReplace()：<br />&nbsp;&nbsp; &nbsp;&nbsp; ON_REGISTERED_MESSAGE(WM_FINDREPLACE, OnFineReplace)<br />&nbsp;&nbsp; 4.最后在CDemoView.cpp末尾编写CDemoView::OnFineReplace()函数了。<br />&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; -《vc++6.0程序设计从入门到精通》<img src ="http://www.cppblog.com/hxg/aggbug/172551.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hxg/" target="_blank">ylka</a> 2012-04-24 10:09 <a href="http://www.cppblog.com/hxg/archive/2012/04/24/172551.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>模乘运算和模幂运算</title><link>http://www.cppblog.com/hxg/archive/2011/06/05/148098.html</link><dc:creator>ylka</dc:creator><author>ylka</author><pubDate>Sun, 05 Jun 2011 03:13:00 GMT</pubDate><guid>http://www.cppblog.com/hxg/archive/2011/06/05/148098.html</guid><wfw:comment>http://www.cppblog.com/hxg/comments/148098.html</wfw:comment><comments>http://www.cppblog.com/hxg/archive/2011/06/05/148098.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/hxg/comments/commentRss/148098.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/hxg/services/trackbacks/148098.html</trackback:ping><description><![CDATA[<div style="background-color:#eeeeee;font-size:13px;border:1px solid #CCCCCC;padding-right: 5px;padding-bottom: 4px;padding-left: 4px;padding-top: 4px;width: 98%;word-break:break-all">unsigned&nbsp;__int64&nbsp;MulMod(unsigned&nbsp;__int64&nbsp;a,unsigned&nbsp;__int64&nbsp;b,unsigned&nbsp;__int64&nbsp;m)&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;(a*b)%n&nbsp;=&nbsp;(a%n)*(b%n)%n</span><span style="color: #008000; "><br /></span>{<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #008000; ">//</span><span style="color: #008000; ">&nbsp;return&nbsp;(a&nbsp;%&nbsp;n)*(b&nbsp;%&nbsp;n&nbsp;)%&nbsp;n;&nbsp;will&nbsp;overflow!so...</span><span style="color: #008000; "><br /></span>&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;__int64&nbsp;s&nbsp;=&nbsp;0,&nbsp;i;<br />&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;%=&nbsp;m;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;b&nbsp;%=&nbsp;m;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">for</span>&nbsp;(i=b;&nbsp;i&gt;0;&nbsp;a&nbsp;=&nbsp;(a&lt;&lt;1)%m,i&gt;&gt;=1)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">if</span>&nbsp;(i&amp;1)&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;=&nbsp;(s+a)&nbsp;%&nbsp;m;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;s;<br />}<br /><br />unsigned&nbsp;__int64&nbsp;PowMod(unsigned&nbsp;__int64&nbsp;<span style="color: #0000FF; ">base</span>,unsigned&nbsp;__int64&nbsp;pow,unsigned&nbsp;__int64&nbsp;n)<span style="color: #008000; ">//</span><span style="color: #008000; ">a^b&nbsp;mod&nbsp;n</span><span style="color: #008000; "><br /></span>{<br />&nbsp;&nbsp;&nbsp;&nbsp;unsigned&nbsp;__int64&nbsp;&nbsp;a=<span style="color: #0000FF; ">base</span>,&nbsp;b=pow,&nbsp;c=1;<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>&nbsp;(b)<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">while</span>(&nbsp;!(b&nbsp;&amp;&nbsp;1)&nbsp;)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b&gt;&gt;=1;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a=&nbsp;MulMod(a,&nbsp;a,&nbsp;n);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;b--;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c=MulMod(a,&nbsp;c,&nbsp;n);<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #0000FF; ">return</span>&nbsp;c;<br />}</div><img src ="http://www.cppblog.com/hxg/aggbug/148098.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/hxg/" target="_blank">ylka</a> 2011-06-05 11:13 <a href="http://www.cppblog.com/hxg/archive/2011/06/05/148098.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>