锘??xml version="1.0" encoding="utf-8" standalone="yes"?>浪潮AV色综合久久天堂,精品国产乱码久久久久久人妻,国产成人无码久久久精品一http://www.shnenglu.com/sandy/category/768.html楂樻ц兘鏈嶅姟鍣ㄧ璁$畻zh-cnTue, 18 Nov 2008 09:17:55 GMTTue, 18 Nov 2008 09:17:55 GMT60When program crashed (windows)http://www.shnenglu.com/sandy/archive/2008/11/17/67108.html灝忔槑灝忔槑Mon, 17 Nov 2008 05:54:00 GMThttp://www.shnenglu.com/sandy/archive/2008/11/17/67108.htmlhttp://www.shnenglu.com/sandy/comments/67108.htmlhttp://www.shnenglu.com/sandy/archive/2008/11/17/67108.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/67108.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/67108.html闃呰鍏ㄦ枃

灝忔槑 2008-11-17 13:54 鍙戣〃璇勮
]]>
IOCP Tipshttp://www.shnenglu.com/sandy/archive/2008/03/12/44248.html灝忔槑灝忔槑Wed, 12 Mar 2008 03:51:00 GMThttp://www.shnenglu.com/sandy/archive/2008/03/12/44248.htmlhttp://www.shnenglu.com/sandy/comments/44248.htmlhttp://www.shnenglu.com/sandy/archive/2008/03/12/44248.html#Feedback6http://www.shnenglu.com/sandy/comments/commentRss/44248.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/44248.html闃呰鍏ㄦ枃

灝忔槑 2008-03-12 11:51 鍙戣〃璇勮
]]>
澶氳繘紼嬫湇鍔$瀹炵幇-鍏變韓sockethttp://www.shnenglu.com/sandy/archive/2008/03/10/44080.html灝忔槑灝忔槑Mon, 10 Mar 2008 06:09:00 GMThttp://www.shnenglu.com/sandy/archive/2008/03/10/44080.htmlhttp://www.shnenglu.com/sandy/comments/44080.htmlhttp://www.shnenglu.com/sandy/archive/2008/03/10/44080.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/44080.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/44080.html闃呰鍏ㄦ枃

灝忔槑 2008-03-10 14:09 鍙戣〃璇勮
]]>
鐢ㄥ畬鎴愮鍙e啓鐨別cho serverhttp://www.shnenglu.com/sandy/archive/2007/06/06/25670.html灝忔槑灝忔槑Wed, 06 Jun 2007 09:44:00 GMThttp://www.shnenglu.com/sandy/archive/2007/06/06/25670.htmlhttp://www.shnenglu.com/sandy/comments/25670.htmlhttp://www.shnenglu.com/sandy/archive/2007/06/06/25670.html#Feedback9http://www.shnenglu.com/sandy/comments/commentRss/25670.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/25670.html闃呰鍏ㄦ枃

灝忔槑 2007-06-06 17:44 鍙戣〃璇勮
]]>
WinDBG(CDB)瀹炶返1-鏂版墜鎸囧崡http://www.shnenglu.com/sandy/archive/2007/03/13/19723.html灝忔槑灝忔槑Tue, 13 Mar 2007 06:39:00 GMThttp://www.shnenglu.com/sandy/archive/2007/03/13/19723.htmlhttp://www.shnenglu.com/sandy/comments/19723.htmlhttp://www.shnenglu.com/sandy/archive/2007/03/13/19723.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/19723.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/19723.html闃呰鍏ㄦ枃

灝忔槑 2007-03-13 14:39 鍙戣〃璇勮
]]>
SendMessage 鍜?SendMessageTimeouthttp://www.shnenglu.com/sandy/archive/2006/07/21/10288.html灝忔槑灝忔槑Fri, 21 Jul 2006 01:50:00 GMThttp://www.shnenglu.com/sandy/archive/2006/07/21/10288.htmlhttp://www.shnenglu.com/sandy/comments/10288.htmlhttp://www.shnenglu.com/sandy/archive/2006/07/21/10288.html#Feedback1http://www.shnenglu.com/sandy/comments/commentRss/10288.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/10288.html
MSDN涓婇潰鏈変竴孌墊枃瀛楁槸榪欐牱璇寸殑

If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more information on nonqueued messages, see Nonqueued Messages.


緲昏瘧涓涓嬶細

SendMessage : 濡傛灉鎸囧畾紿楀彛鐢辮皟鐢ㄧ嚎紼嬪垱寤猴紝閭d箞紿楀彛榪囩▼浼氳褰撴垚涓涓瓙紼嬪簭绔嬪嵆璋冪敤銆傚鏋滄寚瀹氱獥鍙g敱鍙﹀涓涓嚎紼嬪垱寤猴紝閭d箞緋葷粺浼氬垏鎹㈠埌閭d釜綰跨▼錛屽茍涓旇皟鐢ㄥ悎閫傜殑紿楀彛榪囩▼銆傚湪綰跨▼涔嬮棿浼犻掔殑娑堟伅浠呬粎褰撴帴鏀剁嚎紼嬫墽琛宮essage retrieval code鎵嶄細琚鐞嗐傚彂閫佺嚎紼嬩細琚牭濉炵洿鍒版帴鏀剁嚎紼嬪鐞嗗畬娑堟伅銆?strong>浣嗘槸錛屽彂閫佺嚎紼嬪湪絳夊緟鐨勫悓鏃朵細澶勭悊鏀跺埌鐨刵onqueued messages 銆備負浜嗛樆姝㈣繖涓鐐癸紝浣跨敤甯︽湁SMTO_BLOCK鍙傛暟 鐨凷endMessageTimeout .

=================================鍗庝附鐨勫垎鍓茬嚎===========================

鎴戞浘緇忛亣鍒拌繖涓棶棰橈紝鎴戣皟鐢⊿endMessage鍚戝彟澶栦竴涓嚎紼嬬獥鍙e彂message錛屾湰鏉ヤ互涓轟粬浼氫竴鐩碽lock浣忥紝浣嗘槸浠栧嵈璋冪敤浜嗗彟澶栦竴涓秷鎭殑澶勭悊紼嬪簭錛屽鑷翠簡琛屼負涓嶆紜?strong>鎵浠ヤ竴瀹氳灝忓績浣跨敤SendMessage鍙戠粰鍏朵粬綰跨▼鐨勭獥鍙c?/strong>

鎴戜慨鏀逛簡涓涓嬶紝鎶?br />pWnd->SendMessage(MSG_LOG_MESSAGE, nMsgType, (LPARAM)(LPCTSTR)m_cstrMessage);
鏀規垚浜?br />HWND hWnd = pWnd->GetSafeHwnd();
::SendMessageTimeout(hWnd,MSG_LOG_MESSAGE, nMsgType, (LPARAM)(LPCTSTR)m_cstrMessage,SMTO_BLOCK,15000,0);
瑙e喅浜嗚繖涓猙ug.


灝忔槑 2006-07-21 09:50 鍙戣〃璇勮
]]>
Win32鐨勬椂闂寸被鍨?/title><link>http://www.shnenglu.com/sandy/archive/2006/03/29/4725.html</link><dc:creator>灝忔槑</dc:creator><author>灝忔槑</author><pubDate>Wed, 29 Mar 2006 03:59:00 GMT</pubDate><guid>http://www.shnenglu.com/sandy/archive/2006/03/29/4725.html</guid><wfw:comment>http://www.shnenglu.com/sandy/comments/4725.html</wfw:comment><comments>http://www.shnenglu.com/sandy/archive/2006/03/29/4725.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.shnenglu.com/sandy/comments/commentRss/4725.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sandy/services/trackbacks/4725.html</trackback:ping><description><![CDATA[鍦╓in32鏃墮棿綾誨瀷鏈夎繖鏍峰嚑縐嶇被鍨?font face="Courier New">FILETIME/</font><code>SYSTEMTIME/WINDOWSTIME<br /><br /><font style="BACKGROUND-COLOR: #ffffff" color="#0000ff"><font face="Verdana" size="4">鍏堟彁涓棶棰橈紝濡備綍璁$畻褰撳墠鏃墮棿100澶╀互鍚庣殑鏃墮棿錛屽湪win32涓?/font><br /></font><br />1.SYSTEMTIME <br /><br /></code>SYSTEMTIME鐨勫畾涔夋槸榪欐牱<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">typedef聽</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">聽聽_SYSTEMTIME<br />聽聽聽聽{<br />聽聽聽聽WORD聽wYear;<br />聽聽聽聽WORD聽wMonth;<br />聽聽聽聽WORD聽wDayOfWeek;<br />聽聽聽聽WORD聽wDay;<br />聽聽聽聽WORD聽wHour;<br />聽聽聽聽WORD聽wMinute;<br />聽聽聽聽WORD聽wSecond;<br />聽聽聽聽WORD聽wMilliseconds;<br />聽聽聽聽}聽SYSTEMTIME;</span></div><br />寰堝ぇ錛屾誨叡16涓瓧鑺傘備綘鍙互璋冪敤GetSystemTime鏉ュ彇寰楀綋鍓嶇殑鏃墮棿<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">SYSTEMTIME聽st;<br />::GetSystemTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st);</span></div>浣嗘槸濡傛灉浣犺皟鐢?st.wDay += 100;鏄揪涓嶅埌鏁堟灉鐨勶紝灝嗕細寰楀埌涓涓棤鏁堢殑鏃墮棿鏍煎紡<br /><br />2. FILETIME<br />FILETIME鐨勫畾涔夋槸榪欐牱鐨?br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">typedef聽</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">聽聽_FILETIME<br />聽聽聽聽{<br />聽聽聽聽DWORD聽dwLowDateTime;<br />聽聽聽聽DWORD聽dwHighDateTime;<br />聽聽聽聽}聽FILETIME;</span></div>FILETIME榪欎釜鍚嶅瓧寰堝鎬紝鍏跺疄浠栬窡FILE騫舵病鏈夌洿鎺ュ叧緋伙紝鍙槸寰堝File鐨凙PI涓紝閮戒互榪欎釜涓烘椂闂寸殑綾誨瀷錛屾瘮濡備綘鍙互璋冪敤GetFileTime鏉ュ彇寰桭ile鐨勫垱寤?淇敼/璁塊棶鏃墮棿銆?br />FILETIME鏄竴涓猒_int64銆傚彲浠ヨ繖鏍瘋漿鍖栨垚__int64<br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">__int64聽d聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">(__int64聽</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st;<br /><br /></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">or</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000"><br />__int64聽d2;<br />memcpy(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">d2,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(d2));</span></div><br />杞寲涓篲_int64鏄竴涓互100綰崇涓哄崟浣嶇殑鍊?br />琛ヤ範涓涓嬫椂闂村崟浣?<a >http://blog.vckbase.com/zaboli/archive/2005/06/29/8969.aspx</a>)<br /><table style="WIDTH: 528px; HEIGHT: 116px" width="528" border="0"><tbody><tr><td width="108"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1ms (姣)</font></td><td width="269"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1姣=0.001縐?10-3縐?millisecond)</font></td></tr><tr><td width="108"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1渭s (寰) </font></td><td width="269"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1寰=0.000001=10-6縐?microsecond)</font></td></tr><tr><td width="108"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1ns (綰崇)</font></td><td width="269"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1綰崇=0.000000001縐?10-9縐掞紙<font color="#000000" size="3">nanosecond</font>)</font></td></tr><tr><td width="108"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1ps (鐨)</font></td><td width="269"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1鐨=0.000000000001縐?10-12縐?/font></td></tr><tr><td width="108"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1fs (椋炵)</font></td><td width="269"><font face="榛戜綋, 鍗庢枃涓畫, 闅朵功, 鏂板畫浣? color="#330099" size="2">1椋炵=0.00000000000001縐?10-15縐?/font></td></tr></tbody></table><br />SYSTEMTIME鍙互閫氳繃SystemTimeToFileTime鏉ヨ漿鍖栦負FILETIME<br /><br />3.Window Time<br />::GetTickCount()鍙互榪斿洖褰撳墠鐨勪互寰涓哄崟浣嶇殑鏃墮棿錛岀敤鍦ㄧ簿搴﹁姹備笉楂樼殑鍦哄悎錛岃繑鍥炵殑鍙槸涓涓狣WORD錛屽洓瀛楄妭銆傞珮涓鐐圭殑浣跨敤timeGetTime<br /><br /><font face="Courier New" color="#0000ff">濡備綍璁$畻褰撳墠鏃墮棿100澶╀互鍚庣殑鏃墮棿錛屽湪win32涓?br />搴旇榪欐牱鍐?br /></font><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">聽__int64聽nano100SecInDay</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(__int64)</span><span style="COLOR: #000000">10000000</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">60</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">60</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">24</span><span style="COLOR: #000000">;<br /><br />SYSTEMTIME聽st;<br />::GetSystemTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st);<br />FILETIME聽f;<br />::SystemTimeToFileTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f);<br />ULARGE_INTEGER聽now;<br />memcpy(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">now,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(now));<br />now聽</span><span style="COLOR: #000000">+=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">100</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">nano100SecInDay;<br />memcpy(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">now,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(f));<br />FileTimeToSystemTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st);<br /></span></div><br /><br />鏈鍚庯細闄勪笂鎴戝啓鐨勪竴涓皬宸ュ叿錛屽垹闄ゆ寚瀹氭枃浠跺す涓嬮潰鐨勮繃鏈熸枃浠剁殑涓涓伐鍏鳳紝騫跺彲浠ュ浠斤紝鏀寔瀛愭枃浠跺す宓屽銆?br /><br /><div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><span style="COLOR: #000000">#include聽</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">windows.h</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br />#include聽</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">cstdio</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br />#include聽</span><span style="COLOR: #000000"><</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">></span><span style="COLOR: #000000"><br /></span><span style="COLOR: #0000ff">using</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">namespace</span><span style="COLOR: #000000">聽std;<br /><br /></span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">聽__int64聽nano100SecInDay</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(__int64)</span><span style="COLOR: #000000">10000000</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">60</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">60</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">24</span><span style="COLOR: #000000">;<br />ULARGE_INTEGER聽now;<br /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽days聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">14</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000">聽backup聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br /></span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽dst_dir;<br /></span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽backup_dir;<br /><br /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">聽make_sure_dir_exist(</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">聽file)<br />{<br />聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽tag聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">;<br />聽聽聽聽</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽tag聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽file.find_first_of(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">\\</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,tag</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(tag</span><span style="COLOR: #000000">!=-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽tmp聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽file.substr(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,tag);<br />聽聽聽聽聽聽聽聽聽聽聽聽::CreateDirectory(tmp.c_str(),NULL);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />}<br /><br /></span><span style="COLOR: #0000ff">void</span><span style="COLOR: #000000">聽xdel(</span><span style="COLOR: #0000ff">const</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">dir)<br />{<br />聽聽聽聽</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">聽tempFileFind[</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">];<br />聽聽聽聽sprintf(tempFileFind,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s\\*.*</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,dir);<br />聽聽聽聽<br />聽聽聽聽WIN32_FIND_DATA聽ffd;<br />聽聽聽聽HANDLE聽hFind;<br />聽聽聽聽hFind聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽::FindFirstFile(tempFileFind,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ffd);<br />聽聽聽聽<br />聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(hFind聽</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">聽INVALID_HANDLE_VALUE)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">can't聽find聽%s\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,dir);<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">;<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="COLOR: #0000ff">while</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">printf("find聽%s\n",ffd.cFileName);</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽聽聽聽聽FILETIME聽</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ft聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽ffd.ftLastWriteTime;<br />聽聽聽聽聽聽聽聽ULARGE_INTEGER聽ui;<br />聽聽聽聽聽聽聽聽memcpy(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ui,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ft,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(ui));<br />聽聽聽聽聽聽聽聽__int64聽t聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽now.QuadPart</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">ui.QuadPart;<br />聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(ffd.dwFileAttributes</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">FILE_ATTRIBUTE_DIRECTORY)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(strcmp(ffd.cFileName,聽</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">.</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)聽</span><span style="COLOR: #000000">&&</span><span style="COLOR: #000000">聽strcmp(ffd.cFileName,聽</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">..</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">))<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">聽temp[</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">];<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽sprintf(temp,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s\\%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,dir,ffd.cFileName);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽xdel(temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(t</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">nano100SecInDay</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">days)<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(::RemoveDirectory(temp))<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">del聽dir聽%s聽ok\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">del聽dir聽%s聽failed\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">聽temp[</span><span style="COLOR: #000000">1024</span><span style="COLOR: #000000">];<br />聽聽聽聽聽聽聽聽聽聽聽聽sprintf(temp,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">%s\\%s</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,dir,ffd.cFileName);<br />聽聽聽聽聽聽聽聽聽聽聽聽<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(t</span><span style="COLOR: #000000">>=</span><span style="COLOR: #000000">nano100SecInDay</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">days)<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(backup)<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽backup_file聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽temp;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽backup_file.replace(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,dst_dir.length(),backup_dir.c_str());<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽make_sure_dir_exist(backup_file);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(::MoveFile(temp,backup_file.c_str()))<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">backup聽file聽%s聽ok\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">backup聽file聽%s聽failed\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽SetFileAttributes(temp,FILE_ATTRIBUTE_NORMAL);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(::DeleteFile(temp))<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">del聽file聽%s聽ok\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">del聽file聽%s聽failed\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,temp);<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">聽(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">FindNextFile(hFind,聽</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ffd))聽<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">break</span><span style="COLOR: #000000">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽FindClose(hFind);<br />}<br /><br /></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽main(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽argc,</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">**</span><span style="COLOR: #000000">聽argv)<br />{<br />聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(argc</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">2</span><span style="COLOR: #000000">)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">usage:聽xdel聽directory聽/d=聽/m=\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">[optional]聽/d:聽config聽the聽expired聽days,default聽is聽14聽days\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">[optional]聽/m:聽config聽the聽backup聽directory\n</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);聽<br />聽聽聽聽聽聽聽聽printf(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">for聽example:聽xdel聽d:\\test聽/d=10聽/m=d:\\backup</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="COLOR: #0000ff">for</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽i</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;i</span><span style="COLOR: #000000"><</span><span style="COLOR: #000000">argc;</span><span style="COLOR: #000000">++</span><span style="COLOR: #000000">i)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">string</span><span style="COLOR: #000000">聽tmp聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽argv[i];<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(tmp.find(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/d=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">!=-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">聽d聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽atoi(tmp.substr(</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">).c_str());<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(d</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">)<br />聽聽聽聽聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽days聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">d;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(tmp.find(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">/m=</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">!=-</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">)<br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽backup聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br />聽聽聽聽聽聽聽聽聽聽聽聽backup_dir聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽tmp.substr(</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">);<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: #0000ff">else</span><span style="COLOR: #000000"><br />聽聽聽聽聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽dst_dir聽</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">聽tmp;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽}<br />聽聽聽聽<br />聽聽聽聽</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">Get聽system聽time</span><span style="COLOR: #008000"><br /></span><span style="COLOR: #000000">聽聽聽聽SYSTEMTIME聽st;<br />聽聽聽聽::GetSystemTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st);<br />聽聽聽聽FILETIME聽f;<br />聽聽聽聽::SystemTimeToFileTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">st,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f);<br />聽聽聽聽memcpy(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">now,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">f,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(now));<br />聽聽聽聽<br />聽聽聽聽xdel(argv[</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">]);<br />聽聽聽聽<br />聽聽聽聽</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">聽</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br />}</span></div><br /><br /><br /><img src ="http://www.shnenglu.com/sandy/aggbug/4725.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sandy/" target="_blank">灝忔槑</a> 2006-03-29 11:59 <a href="http://www.shnenglu.com/sandy/archive/2006/03/29/4725.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鏈綆鍗曠殑MFC紼嬪簭http://www.shnenglu.com/sandy/archive/2006/01/24/3003.html灝忔槑灝忔槑Tue, 24 Jan 2006 04:01:00 GMThttp://www.shnenglu.com/sandy/archive/2006/01/24/3003.htmlhttp://www.shnenglu.com/sandy/comments/3003.htmlhttp://www.shnenglu.com/sandy/archive/2006/01/24/3003.html#Feedback2http://www.shnenglu.com/sandy/comments/commentRss/3003.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/3003.html  闃呰鍏ㄦ枃

灝忔槑 2006-01-24 12:01 鍙戣〃璇勮
]]>
浠涔堟墠鏄綰跨▼瀹夊叏鐨?/title><link>http://www.shnenglu.com/sandy/archive/2006/01/12/2690.html</link><dc:creator>灝忔槑</dc:creator><author>灝忔槑</author><pubDate>Thu, 12 Jan 2006 09:45:00 GMT</pubDate><guid>http://www.shnenglu.com/sandy/archive/2006/01/12/2690.html</guid><wfw:comment>http://www.shnenglu.com/sandy/comments/2690.html</wfw:comment><comments>http://www.shnenglu.com/sandy/archive/2006/01/12/2690.html#Feedback</comments><slash:comments>17</slash:comments><wfw:commentRss>http://www.shnenglu.com/sandy/comments/commentRss/2690.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sandy/services/trackbacks/2690.html</trackback:ping><description><![CDATA[瀵逛簬澶氱嚎紼嬬紪紼嬶紝寰堝浜烘蹇典笉娓咃紝鍐欎唬鐮佺殑鏃跺欒涔堟槸澶勫鍔犻攣錛屽獎鍝嶆ц兘涓嶈錛岃繕瀹規槗鑾悕鍏跺鐨勬閿侊紝榪樻湁浜哄澶氱嚎紼嬫暚鑰岃繙涔嬨?BR><BR>鎵浠ュ涔犲綰跨▼緙栫▼鏈閲嶈鐨勪笉鏄涔燗PI,鑰屾槸鐞嗚В浠涔堟墠鏄綰跨▼瀹夊叏鐨勪唬鐮?BR><BR>浠庝緥瀛愯璧?BR><BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">windows.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">process.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><BR></SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> global1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #0000ff">volatile</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> global2 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000"> MyClass<BR>{<BR></SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">:<BR>    MyClass() : m(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">m;<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> fun(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> v)<BR>    {<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> m</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">v; </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-----------9</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> v)<BR>    {<BR>        m </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> v;   </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------------10</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    }<BR>    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> m;<BR>};<BR><BR>MyClass global_object; </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------------8</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> __stdcall thread_fun1(</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">param)<BR>{<BR>    </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> static2 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000"> MyClass static_object; </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">--------6</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> local1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>    <BR>    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">local1;     </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------1</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">static2;    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------2</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">global1;    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------3</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">global2;    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------4</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    InterlockedIncrement(</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">global1); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">--------5</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>    local1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> global_object.fun(local1); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">----------7</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>    global_object.</SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">(local1); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">---------------11</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}<BR><BR><BR>unsigned </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> __stdcall thread_fun2(</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">param)<BR>{<BR>    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">global1;    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------3</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">global2;    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-------4</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    InterlockedIncrement(</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">global1); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">--------5</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000"><BR>    global_object.</SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">-----------11</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}<BR><BR><BR></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> main()<BR>{<BR>    HANDLE thread1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (HANDLE)_beginthreadex(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">thread_fun1,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">thread 1</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    HANDLE thread2 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (HANDLE)_beginthreadex(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">thread_fun1,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">thread 2</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    HANDLE thread3 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (HANDLE)_beginthreadex(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">thread_fun2,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">thread 3</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    <BR>    WaitForSingleObject(thread1,INFINITE);<BR>    WaitForSingleObject(thread2,INFINITE);<BR>    WaitForSingleObject(thread3,INFINITE);<BR>    <BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}<BR><BR></SPAN></DIV><BR><BR><STRONG>1.灞閮ㄥ彉閲忓眬閮ㄤ嬌鐢ㄦ槸瀹夊叏鐨?/STRONG><BR>涓轟粈涔?鍥犱負姣忎釜thread 閮芥湁鑷繁鐨勮繍琛屽爢鏍堬紝鑰屽眬閮ㄥ彉閲忔槸鐢熷瓨鍦ㄥ爢鏍堜腑,澶у涓嶅共鎵般?BR>鎵浠ヤ唬鐮?<BR>int local1;<BR>++local1;<BR>鏄畨鍏ㄧ殑<BR><BR><STRONG>2.鍏ㄥ眬鍘熺敓鍙橀噺澶氱嚎紼嬭鍐欐槸涓嶅畨鍏ㄧ殑<BR></STRONG>鍏ㄥ眬鍙橀噺鏄湪鍫?heap)涓?BR>long global1 = 0;<BR>++global2;<BR>++榪欎釜鎿嶄綔鍏跺疄鍒嗕負涓ら儴錛屼竴涓槸璇伙紝鍙﹀涓涓槸鍐?BR> mov         ecx,global<BR> add         ecx,1<BR> mov         global,ecx<BR>鎵浠ヤ唬鐮?澶勬槸涓嶅畨鍏ㄧ殑<BR><BR><STRONG>3.鍑芥暟闈欐佸彉閲忓綰跨▼璇誨啓涔熸槸涓嶅畨鍏ㄧ殑<BR></STRONG>閬撶悊鍚?<BR>鎵浠ヤ唬鐮?澶勪篃鏄笉瀹夊叏鐨?BR><BR><STRONG>4.volatile鑳戒繚璇佸叏灞鏁村艦鍙橀噺鏄綰跨▼瀹夊叏鐨勪箞</STRONG><BR>涓嶈兘銆?BR>volatile浠呬粎鏄憡璇玞ompiler涓嶈瀵硅繖涓彉閲忎綔浼樺寲錛屾瘡嬈¢兘瑕佷粠memory鍙栨暟鍊鹼紝鑰屼笉鏄粠register<BR>鎵浠ヤ唬鐮?涔熶笉鏄畨鍏?BR><BR><STRONG>5.InterlockedIncrement淇濊瘉鏁村瀷鍙橀噺鑷鐨勫師瀛愭?/STRONG><BR>鎵浠ヤ唬鐮?鏄畨鍏ㄧ殑<BR><BR><STRONG>6.function static object鐨勫垵濮嬪寲鏄綰跨▼瀹夊叏鐨勪箞</STRONG><BR>涓嶆槸銆?BR>钁楀悕鐨凪eyer Singleton鍏跺疄涓嶆槸綰跨▼瀹夊叏鐨?BR>Object & getInstance()<BR>{ <BR>     static Object o;<BR>     return o;<BR>}<BR>鍙兘浼氶犳垚澶氭鍒濆鍖栧璞?BR>鎵浠ヤ唬鐮?澶勬槸涓嶅畨鍏ㄧ殑<BR><BR><STRONG>7.鍦?2鏈哄櫒涓婏紝4瀛楄妭鏁村艦涓嬈ssign鏄師瀛愮殑</STRONG><BR>姣斿<BR>i =10; //thread1<BR>i=4; //thread2<BR>涓嶄細瀵艱嚧i鐨勫煎浜庢湭鐭ョ姸鎬?瑕佷箞鏄?0瑕佷箞鏄?<BR><BR>鍏跺畠鐨勫ぇ瀹惰嚜宸卞幓浣撲細銆?BR><BR>鍐欏ソ澶氱嚎紼嬪畨鍏ㄧ殑娉曞疂灝辨槸灝佽錛屼嬌鏁版嵁鏈変繚鎶ょ殑琚闂埌<BR>瀹夊叏鎬э細<BR>灞閮ㄥ彉閲?gt;鎴愬憳鍙橀噺>鍏ㄥ眬鍙橀噺<img src ="http://www.shnenglu.com/sandy/aggbug/2690.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sandy/" target="_blank">灝忔槑</a> 2006-01-12 17:45 <a href="http://www.shnenglu.com/sandy/archive/2006/01/12/2690.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浣跨敤PostThreadMessage鍦╓in32綰跨▼闂翠紶閫掓秷鎭?/title><link>http://www.shnenglu.com/sandy/archive/2005/12/31/2320.html</link><dc:creator>灝忔槑</dc:creator><author>灝忔槑</author><pubDate>Sat, 31 Dec 2005 07:31:00 GMT</pubDate><guid>http://www.shnenglu.com/sandy/archive/2005/12/31/2320.html</guid><wfw:comment>http://www.shnenglu.com/sandy/comments/2320.html</wfw:comment><comments>http://www.shnenglu.com/sandy/archive/2005/12/31/2320.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/sandy/comments/commentRss/2320.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sandy/services/trackbacks/2320.html</trackback:ping><description><![CDATA[<P><STRONG>PostThreadMessage</STRONG>鐨勫師鍨嬫槸榪欐牱鐨?/P> <P>BOOL PostThreadMessage( DWORD idThread,<BR>    UINT Msg,<BR>    WPARAM wParam,<BR>    LPARAM lParam<BR>);<BR><BR><STRONG>PostThreadMessage</STRONG>鍙互鐢ㄤ簬綰跨▼涔嬮棿鐨勫紓姝ラ氳錛屽洜涓哄畠涓嶇敤絳夊緟璋冪敤鑰呰繑鍥烇紝<BR>榪欎篃璁告槸綰跨▼閫氳涓渶綆鍗曠殑涓縐嶆柟娉曚簡銆?BR><BR>浣嗘槸瑕佹敞鎰忎互涓嬮棶棰?BR>1 .PostThreadMessage鏈夋椂浼氬け璐ワ紝鎶?444閿欒(Invalid thread identifier. )<BR>鍏跺疄榪欎笉涓瀹氭槸綰跨▼涓嶅瓨鍦ㄧ殑鍘熷洜錛屼篃鏈夊彲鑳芥槸綰跨▼涓嶅瓨鍦ㄦ秷鎭槦鍒?message queue)閫犳垚鐨勩?BR>浜嬪疄涓婏紝騫朵笉鏄瘡涓猼hread閮芥湁message queue,閭e浣曡thread鍏鋒湁鍛紵<BR>絳旀鏄紝鑷沖皯璋冪敤message鐩稿叧鐨刦unction涓嬈★紝姣斿GetMessage,PeekMessage銆?BR><BR>2.濡傛灉鏄痯ost鍔ㄦ佸垎閰嶇殑memory緇欏彟澶栦竴涓猼hread,瑕佹敞鎰忓唴瀛樼殑姝g‘閲婃斁銆?BR><BR>3.PostThreadMessage涓嶈兘澶焢ost WM_COPYDATE涔嬬被鐨勫悓姝ユ秷鎭紝鍚﹀垯浼氭姤閿?BR><BR>4.鏈濂戒笉瑕佷嬌鐢≒ostThreadMessage post message緇欎竴涓獥鍙?浣跨敤PostMessage鏇夸唬銆?BR><BR>涓嬮潰鏄垜鍐欑殑涓涓瘮杈冧弗鏁寸殑渚嬪瓙錛屼粎渚涘弬鑰冦?BR></P> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">windows.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">cstdio</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">process.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><BR></SPAN><SPAN style="COLOR: #0000ff">#define</SPAN><SPAN style="COLOR: #000000"> MY_MSG WM_USER+100</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> MAX_INFO_SIZE </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">20</SPAN><SPAN style="COLOR: #000000">;<BR><BR>HANDLE hStartEvent; </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> thread start event<BR><BR></SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> thread function</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">unsigned __stdcall fun(</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">param)<BR>{<BR>    printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">thread fun start<IMG src="http://www.shnenglu.com/images/dot.gif">\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR><BR>    MSG msg;<BR>    PeekMessage(</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">msg, NULL, WM_USER, WM_USER, PM_NOREMOVE);<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">SetEvent(hStartEvent)) </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">set thread start event </SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">set start event failed,errno:%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,::GetLastError());<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR>    <BR>    </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(GetMessage(</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">msg,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)) </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">get msg from message queue</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        {<BR>            </SPAN><SPAN style="COLOR: #0000ff">switch</SPAN><SPAN style="COLOR: #000000">(msg.message)<BR>            {<BR>            </SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000"> MY_MSG:<BR>                </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> pInfo </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">)msg.wParam;<BR>                printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">recv %s\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,pInfo);<BR>                delete[] pInfo;<BR>                </SPAN><SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #000000">;<BR>            }<BR>        }<BR>    };<BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}<BR><BR></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> main()<BR>{<BR>    HANDLE hThread;<BR>    unsigned nThreadID;<BR><BR>    hStartEvent </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> ::CreateEvent(</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,FALSE,FALSE,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">); </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">create thread start event</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(hStartEvent </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">create start event failed,errno:%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,::GetLastError());<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">start thread</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    hThread </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> (HANDLE)_beginthreadex( NULL, </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">, </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">fun, NULL, </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">, </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">nThreadID );<BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(hThread </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">start thread failed,errno:%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,::GetLastError());<BR>        CloseHandle(hStartEvent);<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">wait thread start event to avoid PostThreadMessage return errno:1444</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    ::WaitForSingleObject(hStartEvent,INFINITE);<BR>    CloseHandle(hStartEvent);<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> count </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> pInfo </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000">[MAX_INFO_SIZE]; </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">create dynamic msg</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        sprintf(pInfo,</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">msg_%d</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">count);<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">PostThreadMessage(nThreadID,MY_MSG,(WPARAM)pInfo,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">))</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">post thread msg</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        {<BR>            printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">post message failed,errno:%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,::GetLastError());<BR>            delete[] pInfo;<BR>        }<BR>        ::Sleep(</SPAN><SPAN style="COLOR: #000000">1000</SPAN><SPAN style="COLOR: #000000">);<BR>    }<BR><BR>    CloseHandle(hThread);<BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}</SPAN></DIV> <P><STRONG><FONT style="BACKGROUND-COLOR: #ffffff" color=#ff0000>===========Happy New Year==============</FONT></STRONG><BR><BR> </P><img src ="http://www.shnenglu.com/sandy/aggbug/2320.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sandy/" target="_blank">灝忔槑</a> 2005-12-31 15:31 <a href="http://www.shnenglu.com/sandy/archive/2005/12/31/2320.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>涓鴻嫳闆勬棤鏁?鍐欎釜娓告垙淇敼鍣?/title><link>http://www.shnenglu.com/sandy/archive/2005/12/19/1872.html</link><dc:creator>灝忔槑</dc:creator><author>灝忔槑</author><pubDate>Mon, 19 Dec 2005 03:37:00 GMT</pubDate><guid>http://www.shnenglu.com/sandy/archive/2005/12/19/1872.html</guid><wfw:comment>http://www.shnenglu.com/sandy/comments/1872.html</wfw:comment><comments>http://www.shnenglu.com/sandy/archive/2005/12/19/1872.html#Feedback</comments><slash:comments>7</slash:comments><wfw:commentRss>http://www.shnenglu.com/sandy/comments/commentRss/1872.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sandy/services/trackbacks/1872.html</trackback:ping><description><![CDATA[鎴戞槸姣旇緝閾佹潌鐨勮嫳闆勬棤鏁?鐨刦ans,鍦ㄧ綉涓婄湅鍒拌繖鏍風殑鏂囩珷錛?A >http://game.china.com/zh_cn/play/10002765/20021113/11362720.html</A><BR><BR>灝辨槸璁╂垜鏂硅嫳闆勫浼氭墍鏈夋妧鑳斤紝鐪熺殑铔埥鐨?BR>瀛︿細28欏規妧鑳戒慨鏀規硶<BR><IMG height=644 alt=heroes3.jpg src="http://www.shnenglu.com/images/cppblog_com/sandy/heroes3.jpg" width=806 border=0><BR><BR>銆銆<FONT size=2>棣栧厛錛屾妸浣犵殑鑻遍泟鐨勫+鍏佃皟鍒板墠闈㈠嚑鏍兼潵錛屾帴鐫鐢‵PE鏉ユ悳绱€備緥濡備綘鐨勫+鍏墊暟錛氱涓鏍?錛岀浜屾牸14錛岀涓夋牸4錛岄偅涔堝氨鐢?3錛?錛?4錛?錛?錛? 鏉ユ悳绱紝灝卞彲浠ユ壘鍒板湴鍧銆傛樉紺轟負錛?<BR>銆銆澹叺縐嶇被錛?FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF<BR>銆銆 FF FF FF FF FF FF FF FF FF FF FF FF 03 00 00 00錛嶅+鍏墊暟閲?BR>銆銆 0E 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 <BR>銆銆 00 00 00 00 00 00 00 00 01 02 03 04 05 06 07 08<BR>銆銆 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <BR>銆銆 25 26 27 28 01 02 03 04 05 06 07 08 00 00 00 00<BR>銆銆 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 <BR>銆銆 04 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF<BR>銆銆 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF<BR>銆銆 FF鎴?0浣滀負涓鏍鹼紝姣?鏍兼槸浠h〃涓縐嶅睘鎬э紝鐗╁搧錛?鐘舵佺瓑絳夈傚墠闈?8鏍兼槸澹叺鐨勭綾伙紝鎺ヤ笅鏉?8鏍兼槸澹叺鐨勬暟閲忋備緥濡? 鑻遍泟鍙甫7縐嶅+鍏碉紝浣犺姣忕閮芥槸澶╀嬌錛岄偅涔堟妸<BR>銆銆 03 00 00 00 鍓嶉潰鐨凢F FF FF FF 鏀逛負0D 00 00 00銆?濡傛灉浣犺鏁伴噺100錛?閭d箞鎶?BR>銆銆 03 00 00 00 鏀逛負64 00 00 00銆?澹叺鐨勭綾繪槸榪欐牱鍒嗙殑錛?0 00 00 00 鏄灙鍏碉紝<BR>銆銆 01 00 00 00 鏄?榪涘寲涓綰х殑鏋叺錛?2 00 00 00 鏄紦綆墜錛?3 00 00 00 鏄綆墜銆?BR>銆銆 濡傛綾繪帹銆?BR>銆銆 <BR>銆銆 浠?3閭d竴鏍煎紑濮嬫暟錛?8鏍煎悗灝辨槸鑻遍泟鐨勬妧鑳界瓑綰э紝鎺ョ潃鐨?8鏍兼槸鑻遍泟鐨勬妧鑳斤紝<BR>銆銆 涔熷氨鏄粠01鍒?8浠h〃鐨勬槸鑻遍泟鐨勬妧鑳界瓑綰э紝鎶鑳界瓑綰ф渶澶氬彧鑳芥槸3銆?BR>銆銆 01 綆湳絳夌駭 02 瀵昏礬鏈瓑綰?03 鍚庡嫟瀛︾瓑綰?BR>銆銆 04 渚﹀療鏈瓑綰?05 澶栦氦鏈瓑綰?06 鑸搗鏈瓑綰?BR>銆銆 07 棰嗗鏈瓑綰?08 鏅烘収鏈瓑綰?09 紲炵鏈瓑綰?BR>銆銆 10 騫歌繍鏈瓑綰?11 寮歸亾鏈瓑綰?12 楣扮溂鏈瓑綰?BR>銆銆 13 鎷涢瓊鏈瓑綰?14 鐞嗚儲鏈瓑綰?15 鐏郴欖旀硶絳夌駭<BR>銆銆 16 姘旂郴欖旀硶絳夌駭 17 姘寸郴欖旀硶絳夌駭 18 鍦熺郴欖旀硶絳夌駭<BR>銆銆 19 瀛︽湳絳夌駭 20 鎴樻湳絳夌駭 21 鐐湳絳夌駭<BR>銆銆 22 瀛︿範鑳藉姏絳夌駭 23 榪涙敾鏈瓑綰?24 闃插盡鏈瓑綰?<BR></FONT><BR>浣嗘槸姣忔浣跨敤FPE鐪熺殑寰堥夯鐑︼紝鎴戝張鏄緢鎳掔殑浜恒侳PE鍙互鍋氬埌鐨勪簨鎯咃紝鎴戜篃鍙互鍋氬埌銆?BR>鍏跺疄娓告垙淇敼涓嶈繃鏄嬌鐢?STRONG><FONT color=#0000ff>ReadProcessMemory</FONT></STRONG>鍜?STRONG><FONT color=#0000ff>WriteProcessMemory</FONT></STRONG><BR><BR>鑺變簡鍗婂ぉ涓嶆柇鐨勮瘯楠岋紝緇堜簬鍐欏嚭涓涓彲浠ョ敤浜庤嫳闆勬棤鏁?.1鐗堢殑淇敼鍣紝娌℃湁鍐欑晫闈紙I'm lazy-:)錛夛紝榪愯涔嬪悗灝辨槸璁╂垜鏂硅嫳闆勫浼氭墍鏈夋妧鑳姐?BR><BR> <DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">windows.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">tlhelp32.h</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR>#include </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000">cstdio</SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"><BR><BR></SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> MODULE_NAME[] </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Heroes3.exe</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR><BR></SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000"> printError( TCHAR</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> msg )<BR>{<BR>    DWORD eNum;<BR>    TCHAR sysMsg[</SPAN><SPAN style="COLOR: #000000">256</SPAN><SPAN style="COLOR: #000000">];<BR>    TCHAR</SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000"> p;<BR>    <BR>    eNum </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> GetLastError( );<BR>    FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM </SPAN><SPAN style="COLOR: #000000">|</SPAN><SPAN style="COLOR: #000000"> FORMAT_MESSAGE_IGNORE_INSERTS,<BR>        NULL, eNum,<BR>        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Default language</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        sysMsg, </SPAN><SPAN style="COLOR: #000000">256</SPAN><SPAN style="COLOR: #000000">, NULL );<BR>    <BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Trim the end of the line and terminate it with a null</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    p </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> sysMsg;<BR>    </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">( ( </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">p </SPAN><SPAN style="COLOR: #000000">></SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">31</SPAN><SPAN style="COLOR: #000000"> ) </SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000"> ( </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">p </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">9</SPAN><SPAN style="COLOR: #000000"> ) )<BR>        </SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">p;<BR>    </SPAN><SPAN style="COLOR: #0000ff">do</SPAN><SPAN style="COLOR: #000000"> { </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">p</SPAN><SPAN style="COLOR: #000000">--</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">; } </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">( ( p </SPAN><SPAN style="COLOR: #000000">>=</SPAN><SPAN style="COLOR: #000000"> sysMsg ) </SPAN><SPAN style="COLOR: #000000">&&</SPAN><SPAN style="COLOR: #000000"><BR>        ( ( </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">p </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">.</SPAN><SPAN style="COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000"> ) </SPAN><SPAN style="COLOR: #000000">||</SPAN><SPAN style="COLOR: #000000"> ( </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">p </SPAN><SPAN style="COLOR: #000000"><</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">33</SPAN><SPAN style="COLOR: #000000"> ) ) );<BR>    <BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Display the message</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    printf( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">WARNING: %s failed with error %d (%s)\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, msg, eNum, sysMsg );<BR>}<BR><BR><BR>DWORD findProcessId(</SPAN><SPAN style="COLOR: #0000ff">const</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">module)<BR>{<BR>    DWORD result </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    HANDLE hProcessSnap;<BR>    <BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Take a snapshot of all processes in the system.</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    hProcessSnap </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000"> );<BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">( hProcessSnap </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> INVALID_HANDLE_VALUE )<BR>    {<BR>        printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">CreateToolhelp32Snapshot (of processes)</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> result;<BR>    }<BR>    <BR>    PROCESSENTRY32 pe32;<BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Set the size of the structure before using it.</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    pe32.dwSize </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">sizeof</SPAN><SPAN style="COLOR: #000000">( PROCESSENTRY32 );<BR>    <BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Retrieve information about the first process,<BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> and exit if unsuccessful</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">( </SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">Process32First( hProcessSnap, </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">pe32 ) )<BR>    {<BR>        printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">Process32First</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );  </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Show cause of failure</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        CloseHandle( hProcessSnap );     </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Must clean up the snapshot object!</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> result;<BR>    }<BR>    <BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> Now walk the snapshot of processes, and<BR>    </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000"> display information about each process in turn</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    </SPAN><SPAN style="COLOR: #0000ff">do</SPAN><SPAN style="COLOR: #000000"><BR>    {<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(stricmp(pe32.szExeFile,module)</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR>        {<BR>            printf( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">find process:  %s\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">, module );<BR>            result </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> pe32.th32ProcessID;<BR>            </SPAN><SPAN style="COLOR: #0000ff">break</SPAN><SPAN style="COLOR: #000000">;<BR>        }<BR>        <BR>    } </SPAN><SPAN style="COLOR: #0000ff">while</SPAN><SPAN style="COLOR: #000000">( Process32Next( hProcessSnap, </SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">pe32 ) );<BR>    <BR>    CloseHandle( hProcessSnap );<BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> result;<BR>}<BR><BR></SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> main(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> argc,</SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">*</SPAN><SPAN style="COLOR: #000000">argv[])<BR>{<BR>    DWORD h3pid </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    <BR>    h3pid </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">  findProcessId(MODULE_NAME);<BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(h3pid </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">can't find %s in memory,please make sure the program started!\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,MODULE_NAME);<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    HANDLE h3 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> OpenProcess( PROCESS_ALL_ACCESS, FALSE, h3pid );<BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">( h3 </SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000"> NULL )<BR>    {<BR>      printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">OpenProcess</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );<BR>      </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    unsigned </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> sideOffset</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0x824994</SPAN><SPAN style="COLOR: #000000">;<BR>    unsigned </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> side </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0xff</SPAN><SPAN style="COLOR: #000000">;<BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">ReadProcessMemory(h3,(LPCVOID)sideOffset,</SPAN><SPAN style="COLOR: #000000">&</SPAN><SPAN style="COLOR: #000000">side,</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)) //鏌ユ壘鎴戞柟鐨勯鑹?BR>    {<BR>        printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ReadProcessMemory</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );<BR>        </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(side</SPAN><SPAN style="COLOR: #000000">!=</SPAN><SPAN style="COLOR: #000000">0xff</SPAN><SPAN style="COLOR: #000000">)<BR>    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">find current side:%d\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">)side);<BR>    }<BR>    </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"><BR>    {<BR>        printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">can't find current side\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>        side </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    unsigned </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> heroBaseAddress </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x15216ab</SPAN><SPAN style="COLOR: #000000">;  </SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">hero name start</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">    unsigned </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> name[</SPAN><SPAN style="COLOR: #000000">20</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">{</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">};<BR>    unsigned </SPAN><SPAN style="COLOR: #0000ff">long</SPAN><SPAN style="COLOR: #000000"> temp </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> heroBaseAddress</SPAN><SPAN style="COLOR: #000000">-</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">char</SPAN><SPAN style="COLOR: #000000"> b[</SPAN><SPAN style="COLOR: #000000">28</SPAN><SPAN style="COLOR: #000000">]; //28縐嶆妧鑳?BR>    </SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> size </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">sizeof</SPAN><SPAN style="COLOR: #000000">(b);<BR>    memset(b,</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">,size);<BR>    b[</SPAN><SPAN style="COLOR: #000000">12</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;//涓嶅鎷涢瓊鏈?BR><BR>    </SPAN><SPAN style="COLOR: #0000ff">for</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000"> i</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;i</SPAN><SPAN style="COLOR: #000000"><=</SPAN><SPAN style="COLOR: #000000">155</SPAN><SPAN style="COLOR: #000000">;</SPAN><SPAN style="COLOR: #000000">++</SPAN><SPAN style="COLOR: #000000">i) //涓鍏?56涓狧ero<BR>    {<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">ReadProcessMemory(h3,(LPCVOID)temp,name,</SPAN><SPAN style="COLOR: #0000ff">sizeof</SPAN><SPAN style="COLOR: #000000">(name),</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">))<BR>        {<BR>            printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">ReadProcessMemory</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );<BR>            </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>        }<BR>        </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(name[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">]</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">side)<BR>        {<BR>            printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">find:%s\t</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,name</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">);<BR>            </SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">(</SPAN><SPAN style="COLOR: #000000">!</SPAN><SPAN style="COLOR: #000000">WriteProcessMemory(h3,(LPVOID)(temp</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">0xA7</SPAN><SPAN style="COLOR: #000000">),b,size,</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">))<BR>            {<BR>                printError( </SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">WriteProcessMemory</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000"> );<BR>                </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>            }<BR>            </SPAN><SPAN style="COLOR: #0000ff">else</SPAN><SPAN style="COLOR: #000000"><BR>            {<BR>                printf(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">update skill sucess!\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>            }<BR>        }<BR>        temp </SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0x492</SPAN><SPAN style="COLOR: #000000">;<BR>    }<BR><BR>    CloseHandle(h3);<BR>    </SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>}</SPAN></DIV> <P><BR>闄勫姞:<BR>璁╂垜鏂硅嫳闆勬墍鏈夎嫳闆勫浼氶櫎浜嗘嫑欖傛湳鐨勪互澶栫殑27縐嶆妧鑳界殑灝忕▼搴?/P> <P>浠ュ墠鑻遍泟涓栫晫涔熸湁涓涓繖鏍風殑紼嬪簭錛屼絾鏄増鏈お鑰侊紝涓嶈兘鐢ㄤ簡銆?/P> <P>浣跨敤鐗堟湰:涓枃鐗?.1,鍏朵粬鐗堟湰娌℃湁嫻嬭瘯</P> <P>浣跨敤鏂規硶:榪涘叆娓告垙鍚庯紝榪愯紼嬪簭</P> <P>Download: http://www.shnenglu.com/Files/sandy/h3c.zip</P><img src ="http://www.shnenglu.com/sandy/aggbug/1872.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sandy/" target="_blank">灝忔槑</a> 2005-12-19 11:37 <a href="http://www.shnenglu.com/sandy/archive/2005/12/19/1872.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Nothing is impossible:鑷垹闄ょ殑紼嬪簭http://www.shnenglu.com/sandy/archive/2005/12/07/1580.html灝忔槑灝忔槑Wed, 07 Dec 2005 02:21:00 GMThttp://www.shnenglu.com/sandy/archive/2005/12/07/1580.htmlhttp://www.shnenglu.com/sandy/comments/1580.htmlhttp://www.shnenglu.com/sandy/archive/2005/12/07/1580.html#Feedback1http://www.shnenglu.com/sandy/comments/commentRss/1580.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/1580.html
鐪熺殑娌″姙娉曞垹闄よ嚜韜箞錛?BR>璇瘋繍琛屼笅闈㈢殑浠g爜錛?BR>
#include <windows.h>
#include 
<shlobj.h>

BOOL SelfDelete()
{
  SHELLEXECUTEINFO sei;
  TCHAR szModule [MAX_PATH], szComspec[MAX_PATH], szParams [MAX_PATH];

  
// get file path names:
  if((GetModuleFileName(0,szModule,MAX_PATH)!=0&&
     (GetShortPathName(szModule,szModule,MAX_PATH)
!=0&&
     (GetEnvironmentVariable(
"COMSPEC",szComspec,MAX_PATH)!=0))
  {
    
// set command shell parameters
    lstrcpy(szParams,"/c del ");
    lstrcat(szParams, szModule);
    lstrcat(szParams, 
" > nul");

    
// set struct members
    sei.cbSize       = sizeof(sei);
    sei.hwnd         
= 0;
    sei.lpVerb       
= "Open";
    sei.lpFile       
= szComspec;
    sei.lpParameters 
= szParams;
    sei.lpDirectory  
= 0;
    sei.nShow        
= SW_HIDE;
    sei.fMask        
= SEE_MASK_NOCLOSEPROCESS;

    
// increase resource allocation to program
    SetPriorityClass(GetCurrentProcess(),
                     REALTIME_PRIORITY_CLASS);
    SetThreadPriority(GetCurrentThread(),
                      THREAD_PRIORITY_TIME_CRITICAL);

    
// invoke command shell
    if(ShellExecuteEx(&sei))
    {
      
// suppress command shell process until program exits
      SetPriorityClass(sei.hProcess,IDLE_PRIORITY_CLASS);
      SetProcessPriorityBoost(sei.hProcess,TRUE);

      
// notify explorer shell of deletion
      SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,szModule,0);
      
return TRUE;
    }
    
else // if error, normalize allocation
    {
      SetPriorityClass(GetCurrentProcess(),
                       NORMAL_PRIORITY_CLASS);
      SetThreadPriority(GetCurrentThread(),
                        THREAD_PRIORITY_NORMAL);
    }
  }
  
return FALSE;
}

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     
int       nCmdShow)
{
    
// on program exit
    
// close all handles etc.
    if(!SelfDelete())
    {
      
// add error messaging
    }
    
return 0;    // WinMain exit
  }


紼嬪簭鐨勬濇兂鏄氳繃鍒涘緩涓涓彟澶栫殑榪涚▼(ShellExecuteEx)錛屽啀璧嬩簣鏈繘紼嬫瘮杈冮珮鐨勬潈闄?SetPriorityClass),
絳夎繖涓▼搴忛鍑轟互鍚庯紝閭d釜鏉榪涚▼鐨勮繘紼嬪氨鍙互鍒犻櫎紼嬪簭浜嗭紝鍙﹀紼嬪簭閫氳繃
SHChangeNotify閫氱煡Explorer:紼嬪簭琚垹闄ゃ?BR>
鍏蜂綋API鐨勪嬌鐢ㄦ柟娉曡鐪婱SDN.

ps:榪欎釜紼嬪簭鏄垜鍦ㄨ佸鐨勭綉绔欎笂鎵懼埌鐨勶紝涓嶆槸鎴戝啓鐨勩傛垜鍦╒C6,Win2000 Professional涓婇潰璋冭瘯閫氳繃



灝忔槑 2005-12-07 10:21 鍙戣〃璇勮
]]>
Colorful life:璁╂帶鍒跺彴浜旈鍏壊http://www.shnenglu.com/sandy/archive/2005/12/05/1537.html灝忔槑灝忔槑Mon, 05 Dec 2005 02:49:00 GMThttp://www.shnenglu.com/sandy/archive/2005/12/05/1537.htmlhttp://www.shnenglu.com/sandy/comments/1537.htmlhttp://www.shnenglu.com/sandy/archive/2005/12/05/1537.html#Feedback0http://www.shnenglu.com/sandy/comments/commentRss/1537.htmlhttp://www.shnenglu.com/sandy/services/trackbacks/1537.html
#include <windows.h>
#include 
<string>
#include 
<ctime>

enum Colors
{
    BLACK        
= 0,
    BLUE         
= 1,
    DARK_GREEN   
= 2,
    LIGHT_BLUE   
= 3,
    RED          
= 4,
    PURPLE       
= 5,
    ORANGE       
= 6,
    GREY         
= 7,
    DARKER_GREY  
= 8,
    MEDIUM_BLUE  
= 9,
    LIGHT_GREEN  
= 10,
    TEAL         
= 11,
    RED_ORANGE   
= 12,
    LIGHT_PURPLE 
= 13,
    YELLOW       
= 14,
    WHITE        
= 15
};

void set_cursor(short x, short y)
{
    COORD point 
= {x, y};
    ::SetConsoleCursorPosition(::GetStdHandle(STD_OUTPUT_HANDLE), point);
}

void set_color(unsigned short color)
{
    ::SetConsoleTextAttribute(::GetStdHandle(STD_OUTPUT_HANDLE), color);
}

void delay(unsigned int delay)
{
    ::Sleep(delay);
}

void set_title(std::string title)
{
    ::SetConsoleTitle(title.c_str());
}

void show_cursor(bool show, int size = 25)
{
    CONSOLE_CURSOR_INFO cci;
    
if (size <= 0) size = 1;
    
if (size > 100) size = 100;
    cci.dwSize 
= size;
    cci.bVisible 
= show;
    ::SetConsoleCursorInfo(::GetStdHandle(STD_OUTPUT_HANDLE), 
&cci);
}

void clear_screen()
{
    system(
"cls");
}

浠g爜寰堢畝鍗曪紝涓嶇敤澶氫綔瑙i噴浜?img src ="http://www.shnenglu.com/sandy/aggbug/1537.html" width = "1" height = "1" />

灝忔槑 2005-12-05 10:49 鍙戣〃璇勮
]]>
91久久婷婷国产综合精品青草| 麻豆国内精品久久久久久| 国产精品99久久久精品无码| 久久精品一区二区三区中文字幕| 97久久久精品综合88久久| 久久综合给合久久狠狠狠97色69| 久久久久久精品无码人妻| 久久人妻AV中文字幕| 久久se精品一区二区| 久久免费线看线看| 久久99精品久久久久久水蜜桃| 久久精品?ⅴ无码中文字幕| 欧美午夜A∨大片久久 | 久久只这里是精品66| 国产色综合久久无码有码| 日韩人妻无码一区二区三区久久 | 国产精品久久久久久久久久影院| 久久九九兔免费精品6| 天堂久久天堂AV色综合| 国产精品久久久久…| 精品久久久久一区二区三区| 久久久久久久久久久免费精品 | 亚洲中文字幕无码久久2017| 久久久久亚洲av无码专区| 亚洲国产天堂久久综合网站| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 久久久久亚洲av成人网人人软件 | 大香网伊人久久综合网2020| 久久精品中文字幕大胸| 精品一区二区久久| 久久中文字幕人妻熟av女| 狠狠色丁香久久综合五月| 久久99国产精品久久99小说 | 久久精品亚洲精品国产欧美| 久久精品国产久精国产果冻传媒| 久久99精品久久久久久动态图| 国产激情久久久久影院小草| 久久人人爽人人爽人人AV东京热| 久久97久久97精品免视看| 久久国产色AV免费观看| 久久综合久久美利坚合众国|