﻿<?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++博客-cpp player</title><link>http://www.cppblog.com/chinaspx/</link><description>c++,设计模式，ACE，网络开发，架构设计，MMORPG</description><language>zh-cn</language><lastBuildDate>Thu, 23 Apr 2026 10:12:50 GMT</lastBuildDate><pubDate>Thu, 23 Apr 2026 10:12:50 GMT</pubDate><ttl>60</ttl><item><title>设置线程的名称，转自emule的源码</title><link>http://www.cppblog.com/chinaspx/archive/2010/05/08/114859.html</link><dc:creator>appstudy</dc:creator><author>appstudy</author><pubDate>Sat, 08 May 2010 09:41:00 GMT</pubDate><guid>http://www.cppblog.com/chinaspx/archive/2010/05/08/114859.html</guid><wfw:comment>http://www.cppblog.com/chinaspx/comments/114859.html</wfw:comment><comments>http://www.cppblog.com/chinaspx/archive/2010/05/08/114859.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/chinaspx/comments/commentRss/114859.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chinaspx/services/trackbacks/114859.html</trackback:ping><description><![CDATA[<p>/*<br>Copyright (C)2003 Barry Dunne (<a href="http://www.emule-project.net/">http://www.emule-project.net</a>)<br>&nbsp;<br>This program is free software; you can redistribute it and/or<br>modify it under the terms of the GNU General Public License<br>as published by the Free Software Foundation; either<br>version 2 of the License, or (at your option) any later version.<br>&nbsp;<br>This program is distributed in the hope that it will be useful,<br>but WITHOUT ANY WARRANTY; without even the implied warranty of<br>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&nbsp; See the<br>GNU General Public License for more details.<br>&nbsp;<br>You should have received a copy of the GNU General Public License<br>along with this program; if not, write to the Free Software<br>Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.<br>*/</p>
<p>// Note To Mods //<br>/*<br>Please do not change anything here and release it..<br>There is going to be a new forum created just for the Kademlia side of the client..<br>If you feel there is an error or a way to improve something, please<br>post it in the forum first and let us look at it.. If it is a real improvement,<br>it will be added to the offical client.. Changing something without knowing<br>what all it does can cause great harm to the network if released in mass form..<br>Any mod that changes anything within the Kademlia side will not be allowed to advertise<br>there client on the eMule forum..<br>*/</p>
<p>#include "stdafx.h"<br>#include "./ThreadName.h"</p>
<p>#ifdef _DEBUG<br>#define new DEBUG_NEW<br>#undef THIS_FILE<br>static char THIS_FILE[] = __FILE__;<br>#endif</p>
<p>namespace Kademlia<br>{<br>&nbsp;void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName, ...)<br>&nbsp;{<br>#ifdef DEBUG<br>&nbsp;&nbsp;if (dwThreadID == NULL)<br>&nbsp;&nbsp;&nbsp;return;<br>&nbsp;&nbsp;__try<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_list args;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_start(args, szThreadName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iLenBuf = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *pcharBuffer = NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iLenResult;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iLenBuf += 128;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete[] pcharBuffer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pcharBuffer = new char[iLenBuf];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iLenResult = _vsnprintf(pcharBuffer, iLenBuf, szThreadName, args);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (iLenResult == -1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_end(args);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="COLOR: #ff0000">THREADNAME_INFO info;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwType = 0x1000;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.szName = pcharBuffer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwThreadID = dwThreadID;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwFlags = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(DWORD), (DWORD *)&amp;info);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } __except (EXCEPTION_CONTINUE_EXECUTION)<br>&nbsp;&nbsp;&nbsp;&nbsp; { }<br>&nbsp;&nbsp;&nbsp;&nbsp; delete[] pcharBuffer;<br>&nbsp;}<br>&nbsp;__except (EXCEPTION_CONTINUE_EXECUTION)<br></span>&nbsp;&nbsp;{}<br>#else</p>
<p>&nbsp;&nbsp;UNREFERENCED_PARAMETER(dwThreadID);<br>&nbsp;&nbsp;UNREFERENCED_PARAMETER(szThreadName);<br>#endif</p>
<p>&nbsp;}</p>
<p>&nbsp;void SetThreadName(LPCSTR szThreadName, ...)<br>&nbsp;{<br>#ifdef DEBUG<br>&nbsp;&nbsp;__try<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_list args;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_start(args, szThreadName);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iLenBuf = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char *pcharBuffer = NULL;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int iLenResult;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iLenBuf += 128;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete [] pcharBuffer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pcharBuffer = new char[iLenBuf];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; iLenResult = _vsnprintf(pcharBuffer, iLenBuf, szThreadName, args);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while (iLenResult == -1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; va_end(args);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="COLOR: #ff0000"> THREADNAME_INFO info;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwType = 0x1000;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.szName = pcharBuffer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwThreadID = (DWORD)-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; info.dwFlags = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(DWORD), (DWORD *)&amp;info);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } __except (EXCEPTION_CONTINUE_EXECUTION)<br>&nbsp;&nbsp;&nbsp;&nbsp; { }<br>&nbsp;&nbsp;&nbsp;&nbsp; delete [] pcharBuffer;<br>&nbsp;}<br>&nbsp;__except (EXCEPTION_CONTINUE_EXECUTION)<br>&nbsp;&nbsp;{}<br></span>#else</p>
<p>&nbsp;&nbsp;UNREFERENCED_PARAMETER(szThreadName);<br>#endif</p>
<p>&nbsp;}<br>}<br></p>
<img src ="http://www.cppblog.com/chinaspx/aggbug/114859.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chinaspx/" target="_blank">appstudy</a> 2010-05-08 17:41 <a href="http://www.cppblog.com/chinaspx/archive/2010/05/08/114859.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>把技术卖给不懂技术的人</title><link>http://www.cppblog.com/chinaspx/archive/2010/05/08/114840.html</link><dc:creator>appstudy</dc:creator><author>appstudy</author><pubDate>Sat, 08 May 2010 04:45:00 GMT</pubDate><guid>http://www.cppblog.com/chinaspx/archive/2010/05/08/114840.html</guid><wfw:comment>http://www.cppblog.com/chinaspx/comments/114840.html</wfw:comment><comments>http://www.cppblog.com/chinaspx/archive/2010/05/08/114840.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/chinaspx/comments/commentRss/114840.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chinaspx/services/trackbacks/114840.html</trackback:ping><description><![CDATA[<span class=Apple-style-span style="FONT-SIZE: 16px; COLOR: #4e4e4e; LINE-HEIGHT: 24px; FONT-FAMILY: Tahoma, Verdana, Arial, Helvetica, sans-serif">&nbsp;<a href="http://www.cnblogs.com/dotey/archive/2010/05/07/1729958.html">http://www.cnblogs.com/dotey/archive/2010/05/07/1729958.html</a>
<p><br>&nbsp;</p>
<p><br>&nbsp;</p>
<p>曾参加过一次技术聚会，大多数都是程序员，一起的有台湾的郭安定老师，郭老师经历比较丰富，席间就有人问他，程序员怎么赚钱？郭老师的回答很精辟：&#8220;把技术卖个不懂技术但需要技术的人&#8221;，仔细回味一下，确实是这么个理，一般程序员圈子都比较小，比较宅，打交道的也都是程序员为主的技术圈子，很难把自己和技术推销出去，而且还有很多程序员热衷于把自己的技术推向给程序员，这可真难，比如有人写了一个号称很牛X的权限管理系统，想推销给程序员用顺便卖点钱，这可真难啊，大多数程序员一定会不屑一顾的说：&#8220;这有啥，我也能写一个&#8221;，殊不知程序员的一大乐趣就是&#8220;重复发明轮子&#8221;。</p>
<p>最近有个朋友找我帮忙，他需要刷新网页点击，本来是手动按F5的，太慢太累太辛苦了，但是又没有什么好办法，为了提高效率，还打算花2000块钱买个二手电脑和拉根网线来做这事。很好的哥们，于是就花了半小时帮他写了个小程序，这程序要是程序员看起来肯定不屑一顾，太简单了，但是对于朋友来说可是帮了他大忙，这在他看来太神奇了，不用辛苦去手动按F5了，只要开着程序，挂一晚上就能刷个十几万的点击，最重要是，省了一笔钱买设备。</p>
<p>BTW：绕来绕去其实我这个解决方案又等于造了个新的轮子，有的浏览器本身就支持定时刷新功能(不过还是不能定时清除Cookie)，当然，因为偶也是典型程序员，喜欢造轮子:)</p>
<p>技术，卖个不懂技术的人才值钱，才可最好的体现他的价值。</p>
</span>
<img src ="http://www.cppblog.com/chinaspx/aggbug/114840.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chinaspx/" target="_blank">appstudy</a> 2010-05-08 12:45 <a href="http://www.cppblog.com/chinaspx/archive/2010/05/08/114840.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>变体格式化调试</title><link>http://www.cppblog.com/chinaspx/archive/2010/05/05/114538.html</link><dc:creator>appstudy</dc:creator><author>appstudy</author><pubDate>Wed, 05 May 2010 14:00:00 GMT</pubDate><guid>http://www.cppblog.com/chinaspx/archive/2010/05/05/114538.html</guid><wfw:comment>http://www.cppblog.com/chinaspx/comments/114538.html</wfw:comment><comments>http://www.cppblog.com/chinaspx/archive/2010/05/05/114538.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/chinaspx/comments/commentRss/114538.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/chinaspx/services/trackbacks/114538.html</trackback:ping><description><![CDATA[<p>void DebugOutput(const char *pszFormat,...)<br>{<br>&nbsp;va_list argp;<br>&nbsp;va_start( argp, pszFormat );<br>&nbsp;char strTemp[4096]={'\0'};<br>&nbsp;_vsnprintf( strTemp, sizeof(strTemp), pszFormat, argp );<br>&nbsp;va_end( argp );&nbsp;</p>
<p>&nbsp;OutputDebugString(strTemp);&nbsp;<br>}</p>
<img src ="http://www.cppblog.com/chinaspx/aggbug/114538.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/chinaspx/" target="_blank">appstudy</a> 2010-05-05 22:00 <a href="http://www.cppblog.com/chinaspx/archive/2010/05/05/114538.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>