锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲视频免费看,在线精品一区二区,国内一区二区在线视频观看http://www.shnenglu.com/AutomateProgram/category/12533.html褰撻煶涔愬拰浼犺鍦ㄦ繁澶滀腑娌夊瘋鍚庯紝紼嬪簭鐨勬瘡涓瓧絎﹁繕鍦ㄨ煩鍔紒zh-cnMon, 18 Oct 2010 15:21:57 GMTMon, 18 Oct 2010 15:21:57 GMT60淇敼IAT瀹炵幇鏈繘紼婣PI HOOK http://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129849.html婕傛紓婕傛紓Thu, 14 Oct 2010 07:42:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129849.htmlhttp://www.shnenglu.com/AutomateProgram/comments/129849.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129849.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/129849.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/129849.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/leeeryan/archive/2010/06/08/5656364.aspx

// APIHOOKImageDirectoryEntryToData.cpp : Defines the entry point for the console application.
//

#include 
"stdafx.h"
#include 
<windows.h>
#include 
<imagehlp.h>//ImageDirectoryEntryToData
#pragma comment(lib,"imagehlp.lib")

char *szModName = NULL ;
char *szHacked = "涓嶅ソ鎰忔漢ook鍒頒簡!" ;  
DWORD dwHookFun ;  
PROC dwHookApiAddr;  
PIMAGE_IMPORT_DESCRIPTOR pImportDesc ;  
PIMAGE_THUNK_DATA32 pThunk;  
ULONG uSize ;  
/************************************************************/  
void MYhook()  
{  
    __asm  
    
{  
        mov  esp,ebp  
            push szHacked  
            pop  DWORD PTR [ebp
+12]  
            pop  ebp  
            jmp dwHookApiAddr  
    }
 
}


int main(int argc, char* argv[])
{
    HMODULE hInstance 
=GetModuleHandle(NULL);  
    dwHookFun 
= (DWORD)MYhook;  
    dwHookApiAddr 
= GetProcAddress(LoadLibrary("USER32.dll"), "MessageBoxA") ;  
    
//閫氳繃鍑芥暟)ImageDirectoryEntryToData鑾峰緱IAT  
    
    pImportDesc 
= (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToData(hInstance,  
        TRUE,  
        IMAGE_DIRECTORY_ENTRY_IMPORT,  
        
&uSize) ;  
    
//鎵懼埌瑕丠OOK鐨勫嚱鏁版墍鍦ㄧ殑妯″潡  
    
    
while(pImportDesc->Name)  
    
{  
        szModName 
= (char *)((PBYTE)hInstance+pImportDesc->Name) ;  
        
if (strcmp(szModName,"USER32.dll")==0)  
            
break ;   
        pImportDesc
++ ;  
    }
  
    
//鍘熷鐨凾HUNK淇℃伅鎸囬拡  
    pThunk= (PIMAGE_THUNK_DATA32)((PBYTE)hInstance+pImportDesc->FirstThunk) ;
    
for(;pThunk->u1.Function;pThunk++)  
    
{  
        PROC
* ppfn = (PROC*&pThunk->u1.Function;
        
if (*ppfn == dwHookApiAddr)  
        
{  
            VirtualProtect(
&pThunk->u1.Function, 4096,PAGE_READWRITE,0);  
            pThunk
->u1.Function = (PDWORD)dwHookFun;  
            
break ;  
        }
  
    }
  

    
//瑕乭ook涓嬮潰榪欎釜API  
   MessageBoxA(0,"榪欐槸姝e父鐨?","xicao",0); 

    
return 0;
}



婕傛紓 2010-10-14 15:42 鍙戣〃璇勮
]]>
棰勭紪璇戝ご鏂囦歡浠嬬粛鍜岃鏄?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129846.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Thu, 14 Oct 2010 07:14:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129846.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/129846.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129846.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/129846.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/129846.html</trackback:ping><description><![CDATA[<p>鍘熸枃鍦板潃錛?a >http://www.neu.edu.cn/cxsj/pointchart/c11/Untitled(3).html</a><br></p> <div align=left>TAG:<span>棰勭紪璇戝拰瀹忓畾涔?VC++,棰勭紪璇戝ご鏂囦歡璇存槑</span><span></span></div> <div align=left>TEXT:</div> <div align=left><span>鎵璋撳ご鏂囦歡棰勭紪璇戯紝灝辨槸鎶婁竴涓伐紼?Project)涓嬌鐢ㄧ殑涓浜汳FC鏍囧噯澶存枃浠?濡俉indows.H銆?Afxwin.H)棰勫厛緙栬瘧錛屼互鍚庤宸ョ▼緙栬瘧鏃訛紝涓嶅啀緙栬瘧榪欓儴鍒嗗ご鏂囦歡錛屼粎浠呬嬌鐢ㄩ緙栬瘧鐨勭粨鏋溿傝繖鏍峰彲浠ュ姞蹇紪璇戦熷害錛岃妭鐪佹椂闂淬?/span><span></span></div> <div align=left><span>銆銆 棰勭紪璇戝ご鏂囦歡閫氳繃緙栬瘧stdafx.cpp鐢熸垚錛屼互宸ョ▼鍚嶅懡鍚嶏紝鐢變簬棰勭紪璇戠殑澶存枃浠剁殑鍚庣紑鏄?#8220;pch”錛屾墍浠ョ紪璇戠粨鏋滄枃浠舵槸projectname.pch銆?/span><span></span></div> <div align=left><span>銆銆 緙栬瘧鍣ㄩ氳繃涓涓ご鏂囦歡stdafx.h鏉ヤ嬌鐢ㄩ緙栬瘧澶存枃浠躲俿tdafx.h榪欎釜澶存枃浠跺悕鏄彲浠ュ湪project鐨勭紪璇戣緗噷鎸囧畾鐨勩傜紪璇戝櫒璁や負錛屾墍鏈夊湪鎸囦護#include "stdafx.h"鍓嶇殑浠g爜閮芥槸棰勭紪璇戠殑錛屽畠璺寵繃#include "stdafx. h"鎸囦護錛屼嬌鐢╬rojectname.pch緙栬瘧榪欐潯鎸囦護涔嬪悗鐨勬墍鏈変唬鐮併?/span><span></span></div> <div align=left><span>銆銆 鍥犳錛屾墍鏈夌殑CPP瀹炵幇鏂囦歡絎竴鏉¤鍙ラ兘鏄細#include "stdafx.h"銆?/span><span></span></div> <div align=left><span>銆銆 鍙﹀錛屾瘡涓涓疄鐜版枃浠禖PP閮藉寘鍚簡濡備笅璇彞錛?/span><span></span></div> <div align=left>#ifdef _DEBUG</div> <div align=left>#undef THIS_FILE</div> <div align=left>static char THIS_FILE[] = __FILE__;</div> <div align=left>#endif</div> <div align=left><span>銆銆 榪欐槸琛ㄧず錛屽鏋滅敓鎴愯皟璇曠増鏈紝瑕佹寚紺哄綋鍓嶆枃浠剁殑鍚嶇О銆俖_FILE__鏄竴涓畯錛屽湪緙栬瘧鍣ㄧ紪璇戣繃紼嬩腑緇欏畠璧嬪間負褰撳墠姝e湪緙栬瘧鐨勬枃浠跺悕縐般?/span><span></span></div> <div align=left><span>銆銆 VC榛樿鎯呭喌涓嬩嬌鐢ㄩ緙栬瘧澶?/Yu)錛屼笉鏄庣櫧鐨勫湪鍔犲叆鏂?h鏂囦歡鍚庣紪璇戞椂鎬誨嚭鐜癴atal errorC1010: 鍦ㄦ煡鎵鵑緙栬瘧澶存寚浠ゆ椂閬囧埌鎰忓鐨勬枃浠剁粨灝劇殑閿欒銆傝В鍐蟲柟娉曟槸鍦╥nclude澶存枃浠剁殑鍦版柟鍔犱笂#include"stdafx.h",鎴栬呮墦欏圭洰灞炴э紝鎵懼埌“C/C++”鏂囦歡澶癸紝鍗曞嚮“棰勭紪璇戝ご”灞炴ч〉銆備慨鏀?#8220;鍒涘緩/浣跨敤棰勭紪璇戝ご”灞炴т負“涓嶄嬌鐢ㄩ緙栬瘧澶?#8221;銆?/span><span></span></div> <div align=left><br></div> <p><br><br>PS:<br>棰勭紪璇戝ご鐨勬蹇碉細 </p> <p>鎵璋撶殑棰勭紪璇戝ご灝辨槸鎶婁竴涓伐紼嬩腑鐨勯偅涓閮ㄥ垎浠g爜,棰勫厛緙栬瘧濂芥斁鍦ㄤ竴涓枃浠墮噷(閫氬父鏄?</p> <p>浠?pch涓烘墿灞曞悕鐨?錛岃繖涓枃浠跺氨縐頒負棰勭紪璇戝ご鏂囦歡榪欎簺棰勫厛緙栬瘧濂界殑浠g爜鍙互鏄換浣曠殑 </p> <p>C/C++浠g爜--------鐢氳嚦鏄痠nline鐨勫嚱鏁幫紝浣嗘槸蹇呴』鏄ǔ瀹氱殑錛屽湪宸ョ▼寮鍙戠殑榪囩▼涓笉浼?</p> <p>琚粡甯告敼鍙樸傚鏋滆繖浜涗唬鐮佽淇敼錛屽垯闇瑕侀噸鏂扮紪璇戠敓鎴愰緙栬瘧澶存枃浠躲傛敞鎰忕敓鎴愰緙?</p> <p>璇戝ご鏂囦歡鏄緢鑰楁椂闂寸殑銆傚悓鏃朵綘寰楁敞鎰忛緙栬瘧澶存枃浠墮氬父寰堝ぇ錛岄氬父鏈?-7M澶с傛敞鎰忓強 </p> <p>鏃舵竻鐞嗛偅浜涙病鏈夌敤鐨勯緙栬瘧澶存枃浠躲?</p> <p>涔熻浣犱細闂細鐜板湪鐨勭紪璇戝櫒閮芥湁Time stamp鐨勫姛鑳斤紝緙栬瘧鍣ㄥ湪緙栬瘧鏁翠釜宸ョ▼鐨勬椂鍊欙紝瀹?</p> <p>鍙細緙栬瘧閭d簺緇忚繃淇敼鐨勬枃浠訛紝鑰屼笉浼氬幓緙栬瘧閭d簺浠庝笂嬈$紪璇戣繃錛屽埌鐜板湪娌℃湁琚慨鏀硅繃 </p> <p>鐨勬枃浠躲傞偅涔堜負浠涔堣繕瑕侀緙栬瘧澶存枃浠跺憿錛熺瓟妗堝湪榪欓噷錛屾垜浠煡閬撶紪璇戝櫒鏄互鏂囦歡涓哄崟 </p> <p>浣嶇紪璇戠殑錛屼竴涓枃浠剁粡榪囦慨鏀瑰悗錛屼細閲嶆柊緙栬瘧鏁翠釜鏂囦歡錛屽綋鐒跺湪榪欎釜鏂囦歡閲屽寘鍚殑鎵鏈?</p> <p>澶存枃浠朵腑鐨勪笢瑗匡紙.eg Macro, Preprocesser 錛夐兘瑕侀噸鏂板鐞嗕竴閬嶃俈C鐨勯緙栬瘧澶存枃浠?</p> <p>淇濆瓨鐨勬鏄繖閮ㄥ垎淇℃伅銆備互閬垮厤姣忔閮借閲嶆柊澶勭悊榪欎簺澶存枃浠躲?</p> <p>棰勭紪璇戝ご鐨勪綔鐢細 </p> <p>鏍規(guī)嵁涓婃枃浠嬬粛錛岄緙栬瘧澶存枃浠剁殑浣滅敤褰撶劧灝辨槸鎻愰珮渚垮疁閫熷害浜嗭紝鏈変簡瀹冧綘娌℃湁蹇呰姣忔 </p> <p>閮界紪璇戦偅浜涗笉闇瑕佺粡甯告敼鍙樼殑浠g爜銆傜紪璇戞ц兘褰撶劧灝辨彁楂樹簡銆?</p> <p>棰勭紪璇戝ご鐨勪嬌鐢細 </p> <p>瑕佷嬌鐢ㄩ緙栬瘧澶達紝鎴戜滑蹇呴』鎸囧畾涓涓ご鏂囦歡錛岃繖涓ご鏂囦歡鍖呭惈鎴戜滑涓嶄細緇忓父鏀瑰彉鐨?</p> <p>浠g爜鍜屽叾浠栫殑澶存枃浠訛紝鐒跺悗鎴戜滑鐢ㄨ繖涓ご鏂囦歡鏉ョ敓鎴愪竴涓緙栬瘧澶存枃浠訛紙.pch鏂囦歡錛?</p> <p>鎯沖繀澶у閮界煡閬?StdAfx.h榪欎釜鏂囦歡銆傚緢澶氫漢閮借涓鴻繖鏄疺C鎻愪緵鐨勪竴涓?#8220;緋葷粺綰у埆”鐨?</p> <p>錛岀紪璇戝櫒甯︾殑涓涓ご鏂囦歡銆傚叾瀹炰笉鏄殑錛岃繖涓枃浠跺彲浠ユ槸浠諱綍鍚嶅瓧鐨勩傛垜浠潵鑰冨療涓涓?</p> <p>鍏稿瀷鐨勭敱AppWizard鐢熸垚鐨凪FC Dialog Based銆紼嬪簭鐨勯緙栬瘧澶存枃浠躲傦紙鍥犱負AppWizard </p> <p>浼氫負鎴戜滑鎸囧畾濂藉浣曚嬌鐢ㄩ緙栬瘧澶存枃浠訛紝榛樿鐨勬槸StdAfx.h錛岃繖鏄疺C璧風殑鍚嶅瓧錛夈傛垜浠?</p> <p>浼氬彂鐜拌繖涓ご鏂囦歡閲屽寘鍚簡浠ヤ笅鐨勫ご鏂囦歡錛?</p> <p>#include <afxwin.h> // MFC core and standard components </p> <p>#include <afxext.h> // MFC extensions </p> <p>#include <afxdisp.h> // MFC Automation classes </p> <p>#include <afxdtctl.h> // MFC support for Internet Explorer 4 </p> <p>Common Controls </p> <p>#include <afxcmn.h> </p> <p>榪欎簺姝f槸浣跨敤MFC鐨勫繀欏誨寘鍚殑澶存枃浠訛紝褰撶劧鎴戜滑涓嶅お鍙兘鍦ㄦ垜浠殑宸ョ▼涓慨鏀硅繖浜涘ご鏂?</p> <p>浠剁殑錛屾墍浠ヨ浠栦滑鏄ǔ瀹氱殑銆?</p> <p>閭d箞鎴戜滑濡備綍鎸囧畾瀹冩潵鐢熸垚棰勭紪璇戝ご鏂囦歡銆傛垜浠煡閬撲竴涓ご鏂囦歡鏄笉鑳界紪璇戠殑銆傛墍浠ユ垜 </p> <p>浠繕闇瑕佷竴涓猚pp鏂囦歡鏉ョ敓鎴?pch 鏂囦歡銆傝繖涓枃浠墮粯璁ょ殑灝辨槸StdAfx.cpp銆傚湪榪欎釜鏂囦歡 </p> <p>閲屽彧鏈変竴鍙ヤ唬鐮佸氨鏄細#include “Stdafx.h”銆傚師鍥犳槸鐞嗘墍褰撶劧鐨勶紝鎴戜滑浠呬粎鏄瀹冭兘 </p> <p>澶熺紪璇戣屽凡?D?D?D涔熷氨鏄錛岃鐨勫彧鏄畠鐨?cpp鐨勬墿灞曞悕銆傛垜浠彲浠ョ敤/Yc緙栬瘧寮鍏蟲潵鎸?</p> <p>瀹歋tdAfx.cpp鏉ョ敓鎴愪竴涓?pch鏂囦歡錛岄氳繃/Fp緙栬瘧寮鍏蟲潵鎸囧畾鐢熸垚鐨刾ch鏂囦歡鐨勫悕瀛椼傛墦 </p> <p>寮project ->Setting->C/C++ 瀵硅瘽妗嗐傛妸Category鎸囧悜Precompiled Header銆傚湪宸﹁竟鐨?</p> <p>鏍戝艦瑙嗗浘閲岄夋嫨鏁翠釜宸ョ▼銆 </p> <p>Project Options(鍙充笅瑙掔殑閭d釜鐧界殑鍦版柟)鍙互鐪嬪埌 /Fp “debug/PCH.pch”錛岃繖灝辨槸鎸?</p> <p>瀹氱敓鎴愮殑.pch鏂囦歡鐨勫悕瀛楋紝榛樿鐨勯氬父鏄<宸ョ▼鍚?gt;.pch錛堟垜鐨勭ず渚嬪伐紼嬪悕灝辨槸PCH錛夈?</p> <p>鐒跺悗錛屽湪宸﹁竟鐨勬爲褰㈣鍥鵑噷閫夋嫨StdAfx.cpp.//榪欐椂鍙兘閫変竴涓猚pp鏂囦歡錛?</p> <p>榪欐椂鍘熸潵鐨凱roject Option鍙樻垚浜?Source File Option錛堝師鏉ユ槸宸ョ▼錛岀幇鍦ㄦ槸涓涓枃浠?</p> <p>錛屽綋鐒跺彉浜嗭級銆傚湪榪欓噷鎴戜滑鍙互鐪嬪埌 /Yc寮鍏籌紝/Yc鐨勪綔鐢ㄥ氨鏄寚瀹氳繖涓枃浠舵潵鍒涘緩涓涓?</p> <p>Pch鏂囦歡銆?Yc鍚庨潰鐨勬枃浠跺悕鏄偅涓寘鍚簡紼沖畾浠g爜鐨勫ご鏂囦歡錛屼竴涓伐紼嬮噷鍙兘鏈変竴涓枃 </p> <p>浠剁殑鍙互鏈塝C寮鍏熾俈C灝辨牴鎹繖涓夐」鎶?StdAfx.cpp緙栬瘧鎴愪竴涓狾bj鏂囦歡鍜屼竴涓狿CH鏂囦歡 </p> <p>銆?</p> <p>鐒跺悗鎴戜滑鍐嶉夋嫨涓涓叾瀹冪殑鏂囦歡鏉ョ湅鐪嬶紝//鍏朵粬cpp鏂囦歡 </p> <p>鍦ㄨ繖閲岋紝Precomplier 閫夋嫨浜?Use 鈰嫰鈰竴欏癸紝澶存枃浠舵槸鎴戜滑鎸囧畾鍒涘緩PCH 鏂囦歡鐨剆tda </p> <p>fx.h </p> <p>鏂囦歡銆備簨瀹炰笂錛岃繖閲屾槸浣跨敤宸ョ▼閲岀殑璁劇疆錛岋紙濡傚浘1錛?Yu”stdafx.h”銆?</p> <p>榪欐牱錛屾垜浠氨璁劇疆濂戒簡棰勭紪璇戝ご鏂囦歡銆備篃灝辨槸璇達紝鎴戜滑鍙互浣跨敤棰勭紪璇戝ご鍔熻兘浜嗐備互 </p> <p>涓嬫槸娉ㄦ剰浜嬮」錛?</p> <p>1):濡傛灉浣跨敤浜?Yu錛屽氨鏄浣跨敤浜嗛緙栬瘧錛屾垜浠湪姣忎釜.cpp鏂囦歡鐨勬渶寮澶達紝鎴戝己璋冧竴閬?</p> <p>鏄渶寮澶達紝鍖呭惈 浣犳寚瀹氫駭鐢焢ch鏂囦歡鐨?h鏂囦歡錛堥粯璁ゆ槸stdafx.h錛変笉鐒跺氨浼氭湁闂銆傚 </p> <p>鏋滀綘娌℃湁鍖呭惈榪欎釜鏂囦歡錛屽氨鍛婅瘔浣燯nexpected file end. 濡傛灉浣犱笉鏄湪鏈寮澶村寘鍚殑錛?</p> <p>浣犺嚜宸辮瘯浠ヤ笅灝辯煡閬撲簡錛岀粷瀵規(guī)湁寰堟儕浜虹殑鏁堟灉鈰?. </p> <p>fatal error C1010: unexpected end of file while looking for precompiled </p> <p>header directive </p> <p>Generating Code... </p> <p>2錛夊鏋滀綘鎶妏ch鏂囦歡涓嶅皬蹇冧涪浜嗭紝緙栬瘧鐨勬椂鍊欏氨浼氫駭鐢熷緢澶氱殑涓嶆甯哥殑琛屼負銆傛牴鎹互涓?</p> <p>鐨勫垎鏋愶紝浣犲彧瑕佽緙栬瘧鍣ㄧ敓鎴愪竴涓猵ch鏂囦歡銆備篃灝辨槸璇存妸 stdafx.cpp錛堝嵆鎸囧畾/Yc鐨勯偅涓?</p> <p>cpp鏂囦歡錛変粠鏂扮紪璇戜竴閬嶃傚綋鐒朵綘鍙互鍌誨偦鐨?Rebuild All銆傜畝鍗曚竴鐐瑰氨鏄夋嫨閭d釜cpp </p> <p>鏂囦歡錛屾寜涓涓婥trl + F7灝卞彲浠ヤ簡銆備笉鐒跺彲鏄緢嫻垂鏃墮棿鐨勫摝銆?</p> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/129846.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-10-14 15:14 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/10/14/129846.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Socket 涓浜涚煡璇嗗拰甯歌瘑錛宻ocket鍏ラ棬http://www.shnenglu.com/AutomateProgram/archive/2010/10/11/129457.html婕傛紓婕傛紓Mon, 11 Oct 2010 09:23:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/10/11/129457.htmlhttp://www.shnenglu.com/AutomateProgram/comments/129457.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/10/11/129457.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/129457.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/129457.htmlhttp://www.shnenglu.com/lapcca/archive/2010/09/10/126329.html

榪欎袱澶╃湅csdn鏈変竴浜涘叧浜巗ocket綺樺寘錛宻ocket緙撳啿鍖鴻緗殑闂錛屽彂鐜拌嚜宸變笉鏄緢娓呮錛屾墍浠ユ煡璧勬枡浜嗚В璁板綍涓涓嬶細

涓涓や釜綆鍗曟蹇甸暱榪炴帴涓庣煭榪炴帴錛?br>1.闀胯繛鎺?/p>

    Client鏂逛笌Server鏂瑰厛寤虹珛閫氳榪炴帴錛岃繛鎺ュ緩绔嬪悗涓嶆柇寮錛?鐒跺悗鍐嶈繘琛屾姤鏂囧彂閫佸拰鎺ユ敹銆?/p>

2.鐭繛鎺?/p>

    Client鏂逛笌Server姣忚繘琛屼竴嬈℃姤鏂囨敹鍙戜氦鏄撴椂鎵嶈繘琛岄氳榪炴帴錛屼氦鏄撳畬姣曞悗绔嬪嵆鏂紑榪炴帴銆傛縐嶆柟寮忓父鐢ㄤ簬涓鐐瑰澶氱偣
閫氳錛屾瘮濡傚涓狢lient榪炴帴涓涓猄erver.

浜?浠涔堟椂鍊欓渶瑕佽冭檻綺樺寘闂?

1:濡傛灉鍒╃敤tcp姣忔鍙戦佹暟鎹紝灝變笌瀵規(guī)柟寤虹珛榪炴帴錛岀劧鍚庡弻鏂瑰彂閫佸畬涓孌墊暟鎹悗錛屽氨鍏抽棴榪炴帴錛岃繖鏍峰氨涓嶄細鍑虹幇綺樺寘闂錛堝洜涓哄彧鏈変竴縐嶅寘緇撴瀯,綾諱技浜巋ttp鍗忚錛夈傚叧闂繛鎺ヤ富瑕佽鍙屾柟閮藉彂閫乧lose榪炴帴錛堝弬鑰僼cp鍏抽棴鍗忚錛夈傚錛欰闇瑕佸彂閫佷竴孌靛瓧絎︿覆緇橞錛岄偅涔圓涓嶣寤虹珛榪炴帴錛岀劧鍚庡彂閫佸弻鏂歸兘榛樿濂界殑鍗忚瀛楃濡?hello give me sth abour yourself"錛岀劧鍚嶣鏀跺埌鎶ユ枃鍚庯紝灝卞皢緙撳啿鍖烘暟鎹帴鏀?鐒跺悗鍏抽棴榪炴帴錛岃繖鏍風矘鍖呴棶棰樹笉鐢ㄨ冭檻鍒幫紝鍥犱負澶у閮界煡閬撴槸鍙戦佷竴孌靛瓧絎︺?br>
2錛氬鏋滃彂閫佹暟鎹棤緇撴瀯錛屽鏂囦歡浼犺緭錛岃繖鏍峰彂閫佹柟鍙鍙戦侊紝鎺ユ敹鏂瑰彧綆℃帴鏀跺瓨鍌ㄥ氨ok錛屼篃涓嶇敤鑰冭檻綺樺寘

3錛氬鏋滃弻鏂瑰緩绔嬭繛鎺ワ紝闇瑕佸湪榪炴帴鍚庝竴孌墊椂闂村唴鍙戦佷笉鍚岀粨鏋勬暟鎹紝濡傝繛鎺ュ悗錛屾湁濂藉嚑縐嶇粨鏋勶細
1)"hello give me sth abour yourself"
2)"Don't give me sth abour yourself" 

 閭h繖鏍風殑璇濓紝濡傛灉鍙戦佹柟榪炵畫鍙戦佽繖涓袱涓寘鍑哄幓錛屾帴鏀舵柟涓嬈℃帴鏀跺彲鑳戒細鏄?hello give me sth abour yourselfDon't give me sth abour yourself" 榪欐牱鎺ユ敹鏂瑰氨鍌諱簡錛屽埌搴曟槸瑕佸共鍢涳紵涓嶇煡閬擄紝鍥犱負鍗忚娌℃湁瑙勫畾榪欎箞璇″紓鐨勫瓧絎︿覆錛屾墍浠ヨ澶勭悊鎶婂畠鍒嗗寘錛屾庝箞鍒嗕篃闇瑕佸弻鏂圭粍緇囦竴涓瘮杈冨ソ鐨勫寘緇撴瀯錛屾墍浠ヤ竴鑸彲鑳戒細鍦ㄥご鍔犱竴涓暟鎹暱搴︿箣綾葷殑鍖咃紝浠ョ‘淇濇帴鏀躲?br>

涓?綺樺寘鍑虹幇鍘熷洜錛氬湪嫻佷紶杈撲腑鍑虹幇錛孶DP涓嶄細鍑虹幇綺樺寘錛屽洜涓哄畠鏈夋秷鎭竟鐣?鍙傝僕indows 緗戠粶緙栫▼)
1 鍙戦佺闇瑕佺瓑緙撳啿鍖烘弧鎵嶅彂閫佸嚭鍘伙紝閫犳垚綺樺寘
2 鎺ユ敹鏂逛笉鍙婃椂鎺ユ敹緙撳啿鍖虹殑鍖咃紝閫犳垚澶氫釜鍖呮帴鏀?/p>

瑙e喅鍔炴硶錛?br>涓轟簡閬垮厤綺樺寘鐜拌薄錛屽彲閲囧彇浠ヤ笅鍑犵鎺柦銆備竴鏄浜庡彂閫佹柟寮曡搗鐨勭矘鍖呯幇璞★紝鐢ㄦ埛鍙氳繃緙栫▼璁劇疆鏉ラ伩鍏嶏紝TCP鎻愪緵浜嗗己鍒舵暟鎹珛鍗充紶閫佺殑鎿嶄綔鎸囦護push錛孴CP杞歡鏀跺埌璇ユ搷浣滄寚浠ゅ悗錛屽氨绔嬪嵆灝嗘湰孌墊暟鎹彂閫佸嚭鍘伙紝鑰屼笉蹇呯瓑寰呭彂閫佺紦鍐插尯婊★紱浜屾槸瀵逛簬鎺ユ敹鏂瑰紩璧風殑綺樺寘錛屽垯鍙氳繃浼樺寲紼嬪簭璁捐銆佺簿綆鎺ユ敹榪涚▼宸ヤ綔閲忋佹彁楂樻帴鏀惰繘紼嬩紭鍏堢駭絳夋帾鏂斤紝浣垮叾鍙婃椂鎺ユ敹鏁版嵁錛屼粠鑰屽敖閲忛伩鍏嶅嚭鐜扮矘鍖呯幇璞★紱涓夋槸鐢辨帴鏀舵柟鎺у埗錛屽皢涓鍖呮暟鎹寜緇撴瀯瀛楁錛屼漢涓烘帶鍒跺垎澶氭鎺ユ敹錛岀劧鍚庡悎騫訛紝閫氳繃榪欑鎵嬫鏉ラ伩鍏嶇矘鍖呫?/p>

浠ヤ笂鎻愬埌鐨勪笁縐嶆帾鏂斤紝閮芥湁鍏朵笉瓚充箣澶勩傜涓縐嶇紪紼嬭緗柟娉曡櫧鐒跺彲浠ラ伩鍏嶅彂閫佹柟寮曡搗鐨勭矘鍖咃紝浣嗗畠鍏抽棴浜嗕紭鍖栫畻娉曪紝闄嶄綆浜嗙綉緇滃彂閫佹晥鐜囷紝褰卞搷搴旂敤紼嬪簭鐨勬ц兘錛屼竴鑸笉寤鴻浣跨敤銆傜浜岀鏂規(guī)硶鍙兘鍑忓皯鍑虹幇綺樺寘鐨勫彲鑳芥э紝浣嗗茍涓嶈兘瀹屽叏閬垮厤綺樺寘錛屽綋鍙戦侀鐜囪緝楂樻椂錛屾垨鐢變簬緗戠粶紿佸彂鍙兘浣挎煇涓椂闂存鏁版嵁鍖呭埌杈炬帴鏀舵柟杈冨揩錛屾帴鏀舵柟榪樻槸鏈夊彲鑳芥潵涓嶅強鎺ユ敹錛屼粠鑰屽鑷寸矘鍖呫傜涓夌鏂規(guī)硶铏界劧閬垮厤浜嗙矘鍖咃紝浣嗗簲鐢ㄧ▼搴忕殑鏁堢巼杈冧綆錛屽瀹炴椂搴旂敤鐨勫満鍚堜笉閫傚悎銆?/p>
瑙e喅綺樺寘闂錛?a >http://www.vckbase.com/document/viewdoc/?id=1203

鍦╯ocket 鏂囦歡浼犺緭涓紝鑾峰彇鏌愪釜鐩綍涓嬬殑鎵鏈夋枃浠訛紝濡傛灉涓涓枃浠跺悕浼犺緭涓嬈¢氳鐨勮瘽錛?27.0.0.1涓婃祴璇曟病鏈変粈涔堥棶棰橈紝褰撳湪灞鍩熺綉涓紶杈?嬈′互涓婏紝灝變細鍑虹幇鍖呬涪澶遍棶棰樸傛垜鐚滆繖涓棶棰樿窡綺樺寘鏈夌偣鐩鎬技銆?

婕傛紓 2010-10-11 17:23 鍙戣〃璇勮
]]>
VC涓父瑙侀敊璇拰瑙e喅鏂規(guī)硶http://www.shnenglu.com/AutomateProgram/archive/2010/09/16/126789.html婕傛紓婕傛紓Thu, 16 Sep 2010 10:35:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/09/16/126789.htmlhttp://www.shnenglu.com/AutomateProgram/comments/126789.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/09/16/126789.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/126789.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/126789.html閾炬帴閿欒錛?br>LINK : fatal error LNK1000: Internal error during IncrBuildImage

鍘熸枃鍦板潃錛?a >http://www.a3gs.com/BookViews.asp?InfoID=3425&classID=819

鍦?/span>Win7鏃楄埌鐗堜笅浣跨敤VS2008緙栬瘧紼嬪簭鏃跺嚭鐜?/span>LINK : fatal error LNK1000: Internal error during IncrBuildImage閿欐湁濡備笅涓ょ瑙e喅鏂規(guī)硶錛?/span>

鏂規(guī)硶涓錛氭墦琛ヤ竵

    鍒板井杞綉绔欎笅杞?/span>343461_ENU_i386_zip琛ヤ竵鍖咃紝鐒跺悗鎵撹ˉ涓佹棦鍙?/span>

鏂規(guī)硶浜岋細淇敼欏圭洰璁劇疆

    欏圭洰->灞炴?/span>->閾炬帴鍣?/span>->甯歌 涓嬮潰鐨?#8220;鍚敤澧為噺閾炬帴”錛屽皢“鏄?/span>(/INCREMENTAL)”鏀逛負“鍚?/span>(/INCREMENTAL:NO)”鏃㈠彲銆?br>
ps錛氭壘涓嶅埌琛ヤ竵鍖咃紝灝辨寜絎簩縐嶆柟娉曘?/span>



婕傛紓 2010-09-16 18:35 鍙戣〃璇勮
]]>
紜歡媯嫻嬶細瀹夎銆佸仠鐢ㄣ乽sb璁懼媯鏌?鍜宑#瀹炵幇http://www.shnenglu.com/AutomateProgram/archive/2010/09/13/126529.html婕傛紓婕傛紓Mon, 13 Sep 2010 13:27:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/09/13/126529.htmlhttp://www.shnenglu.com/AutomateProgram/comments/126529.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/09/13/126529.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/126529.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/126529.html闃呰鍏ㄦ枃

婕傛紓 2010-09-13 21:27 鍙戣〃璇勮
]]>
vc/C++涓嬌鐢ㄧ綉緇滄牎姝g郴緇熸椂闂?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118031.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Wed, 16 Jun 2010 10:09:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118031.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/118031.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118031.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/118031.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/118031.html</trackback:ping><description><![CDATA[<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: #008080"> 1</span><img src="http://www.shnenglu.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">BOOL UpdateSysTime()<br></span><span style="COLOR: #008080"> 2</span><span style="COLOR: #000000"><img id=Codehighlighter1_21_2209_Open_Image onclick="this.style.display='none'; Codehighlighter1_21_2209_Open_Text.style.display='none'; Codehighlighter1_21_2209_Closed_Image.style.display='inline'; Codehighlighter1_21_2209_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_21_2209_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_21_2209_Closed_Text.style.display='none'; Codehighlighter1_21_2209_Open_Image.style.display='inline'; Codehighlighter1_21_2209_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_21_2209_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_21_2209_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080"> 3</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    WORD    wVersionRequested;<br></span><span style="COLOR: #008080"> 4</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    WSADATA wsaData;<br></span><span style="COLOR: #008080"> 5</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080"> 6</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 鍒濆鍖栫増鏈?/span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080"> 7</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    wVersionRequested </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> MAKEWORD( </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">, </span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> );<br></span><span style="COLOR: #008080"> 8</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">WSAStartup(wVersionRequested, </span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">wsaData)) <br></span><span style="COLOR: #008080"> 9</span><span style="COLOR: #000000"><img id=Codehighlighter1_168_203_Open_Image onclick="this.style.display='none'; Codehighlighter1_168_203_Open_Text.style.display='none'; Codehighlighter1_168_203_Closed_Image.style.display='inline'; Codehighlighter1_168_203_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_168_203_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_168_203_Closed_Text.style.display='none'; Codehighlighter1_168_203_Open_Image.style.display='inline'; Codehighlighter1_168_203_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_168_203_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_168_203_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">10</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        WSACleanup();<br></span><span style="COLOR: #008080">11</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> FALSE;<br></span><span style="COLOR: #008080">12</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">13</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000"> (LOBYTE(wsaData.wVersion)</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">||</span><span style="COLOR: #000000"> HIBYTE(wsaData.wVersion)</span><span style="COLOR: #000000">!=</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">) <br></span><span style="COLOR: #008080">14</span><span style="COLOR: #000000"><img id=Codehighlighter1_272_309_Open_Image onclick="this.style.display='none'; Codehighlighter1_272_309_Open_Text.style.display='none'; Codehighlighter1_272_309_Closed_Image.style.display='inline'; Codehighlighter1_272_309_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_272_309_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_272_309_Closed_Text.style.display='none'; Codehighlighter1_272_309_Open_Image.style.display='inline'; Codehighlighter1_272_309_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_272_309_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_272_309_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">15</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        WSACleanup( );<br></span><span style="COLOR: #008080">16</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> FALSE; <br></span><span style="COLOR: #008080">17</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">18</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">19</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 榪欎釜IP鏄腑鍥藉ぇ闄嗘椂闂村悓姝ユ湇鍔″櫒鍦板潃錛屽彲鑷淇敼</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">20</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    SOCKET soc</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);<br></span><span style="COLOR: #008080">21</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> sockaddr_in addrSrv;<br></span><span style="COLOR: #008080">22</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    addrSrv.sin_addr.S_un.S_addr</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">inet_addr(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">210.72.145.44</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">23</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    addrSrv.sin_family</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">AF_INET;<br></span><span style="COLOR: #008080">24</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    addrSrv.sin_port</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">htons(</span><span style="COLOR: #000000">123</span><span style="COLOR: #000000">);<br></span><span style="COLOR: #008080">25</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">26</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Packet NTP_Send,NTP_Recv; <br></span><span style="COLOR: #008080">27</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.Control_Word   </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">   htonl(</span><span style="COLOR: #000000">0x0B000000</span><span style="COLOR: #000000">);   <br></span><span style="COLOR: #008080">28</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.root_delay        </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: #008080">29</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.root_dispersion   </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: #008080">30</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.reference_identifier    </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: #008080">31</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.reference_timestamp    </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: #008080">32</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.originate_timestamp    </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: #008080">33</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.receive_timestamp        </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: #008080">34</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.transmit_timestamp_seconds        </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: #008080">35</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    NTP_Send.transmit_timestamp_fractions   </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: #008080">36</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">37</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(SOCKET_ERROR</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">sendto(soc,(</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">&</span><span style="COLOR: #000000">NTP_Send,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(NTP_Send),<br></span><span style="COLOR: #008080">38</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,(</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> sockaddr</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">addrSrv,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(addrSrv)))<br></span><span style="COLOR: #008080">39</span><span style="COLOR: #000000"><img id=Codehighlighter1_1074_1113_Open_Image onclick="this.style.display='none'; Codehighlighter1_1074_1113_Open_Text.style.display='none'; Codehighlighter1_1074_1113_Closed_Image.style.display='inline'; Codehighlighter1_1074_1113_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1074_1113_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1074_1113_Closed_Text.style.display='none'; Codehighlighter1_1074_1113_Open_Image.style.display='inline'; Codehighlighter1_1074_1113_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1074_1113_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1074_1113_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">40</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        closesocket(soc);<br></span><span style="COLOR: #008080">41</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> FALSE;<br></span><span style="COLOR: #008080">42</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">43</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000"> sockaddr_Size </span><span style="COLOR: #000000">=</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(addrSrv);<br></span><span style="COLOR: #008080">44</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(SOCKET_ERROR</span><span style="COLOR: #000000">==</span><span style="COLOR: #000000">recvfrom(soc,(</span><span style="COLOR: #0000ff">char</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">NTP_Recv,</span><span style="COLOR: #0000ff">sizeof</span><span style="COLOR: #000000">(NTP_Recv),<br></span><span style="COLOR: #008080">45</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">,(</span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000"> sockaddr</span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">addrSrv,</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">sockaddr_Size))<br></span><span style="COLOR: #008080">46</span><span style="COLOR: #000000"><img id=Codehighlighter1_1267_1306_Open_Image onclick="this.style.display='none'; Codehighlighter1_1267_1306_Open_Text.style.display='none'; Codehighlighter1_1267_1306_Closed_Image.style.display='inline'; Codehighlighter1_1267_1306_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1267_1306_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1267_1306_Closed_Text.style.display='none'; Codehighlighter1_1267_1306_Open_Image.style.display='inline'; Codehighlighter1_1267_1306_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1267_1306_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1267_1306_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">47</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        closesocket(soc);<br></span><span style="COLOR: #008080">48</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> FALSE;<br></span><span style="COLOR: #008080">49</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">50</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    closesocket(soc);<br></span><span style="COLOR: #008080">51</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    WSACleanup();<br></span><span style="COLOR: #008080">52</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">53</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    SYSTEMTIME    newtime;<br></span><span style="COLOR: #008080">54</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">        Splitseconds;<br></span><span style="COLOR: #008080">55</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">struct</span><span style="COLOR: #000000">        tm    </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000">lpLocalTime;<br></span><span style="COLOR: #008080">56</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    time_t        ntp_time;<br></span><span style="COLOR: #008080">57</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">58</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 鑾峰彇鏃墮棿鏈嶅姟鍣ㄧ殑鏃墮棿</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">59</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    ntp_time    </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> ntohl(NTP_Recv.transmit_timestamp_seconds)</span><span style="COLOR: #000000">-</span><span style="COLOR: #000000">2208988800</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">60</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    lpLocalTime </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> localtime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">ntp_time);<br></span><span style="COLOR: #008080">61</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(lpLocalTime </span><span style="COLOR: #000000">==</span><span style="COLOR: #000000"> NULL)<br></span><span style="COLOR: #008080">62</span><span style="COLOR: #000000"><img id=Codehighlighter1_1579_1598_Open_Image onclick="this.style.display='none'; Codehighlighter1_1579_1598_Open_Text.style.display='none'; Codehighlighter1_1579_1598_Closed_Image.style.display='inline'; Codehighlighter1_1579_1598_Closed_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1579_1598_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1579_1598_Closed_Text.style.display='none'; Codehighlighter1_1579_1598_Open_Image.style.display='inline'; Codehighlighter1_1579_1598_Open_Text.style.display='inline';" src="http://www.shnenglu.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>    </span><span id=Codehighlighter1_1579_1598_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.shnenglu.com/Images/dot.gif"></span><span id=Codehighlighter1_1579_1598_Open_Text><span style="COLOR: #000000">{<br></span><span style="COLOR: #008080">63</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>        </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> FALSE;<br></span><span style="COLOR: #008080">64</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>    }</span></span><span style="COLOR: #000000"><br></span><span style="COLOR: #008080">65</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">66</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 鑾峰彇鏂扮殑鏃墮棿</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">67</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    newtime.wYear      </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_year</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1900</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">68</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wMonth     </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_mon</span><span style="COLOR: #000000">+</span><span style="COLOR: #000000">1</span><span style="COLOR: #000000">;<br></span><span style="COLOR: #008080">69</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wDayOfWeek </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_wday;<br></span><span style="COLOR: #008080">70</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wDay       </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_mday;<br></span><span style="COLOR: #008080">71</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wHour      </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_hour;<br></span><span style="COLOR: #008080">72</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wMinute    </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_min;<br></span><span style="COLOR: #008080">73</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wSecond    </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">lpLocalTime</span><span style="COLOR: #000000">-></span><span style="COLOR: #000000">tm_sec;<br></span><span style="COLOR: #008080">74</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">75</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 璁劇疆鏃墮棿綺懼害</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">76</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    Splitseconds</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">)ntohl(NTP_Recv.transmit_timestamp_fractions);<br></span><span style="COLOR: #008080">77</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    Splitseconds</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">0.000000000200</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> Splitseconds;<br></span><span style="COLOR: #008080">78</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    Splitseconds</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">(</span><span style="COLOR: #0000ff">float</span><span style="COLOR: #000000">)</span><span style="COLOR: #000000">1000.0</span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> Splitseconds;<br></span><span style="COLOR: #008080">79</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    newtime.wMilliseconds   </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">   (unsigned   </span><span style="COLOR: #0000ff">short</span><span style="COLOR: #000000">)Splitseconds;<br></span><span style="COLOR: #008080">80</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    <br></span><span style="COLOR: #008080">81</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"> 淇敼鏈満緋葷粺鏃墮棿</span><span style="COLOR: #008000"><br></span><span style="COLOR: #008080">82</span><span style="COLOR: #008000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">    SetLocalTime(</span><span style="COLOR: #000000">&</span><span style="COLOR: #000000">newtime);<br></span><span style="COLOR: #008080">83</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/InBlock.gif" align=top>    </span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000"> TRUE;<br></span><span style="COLOR: #008080">84</span><span style="COLOR: #000000"><img src="http://www.shnenglu.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/118031.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-06-16 18:09 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118031.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>浣跨敤CInternetSession鍜孋HttpFile璇誨彇緗戦〉鍐呭http://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118030.html婕傛紓婕傛紓Wed, 16 Jun 2010 10:03:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118030.htmlhttp://www.shnenglu.com/AutomateProgram/comments/118030.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/06/16/118030.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/118030.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/118030.htmlhttp://www.398588.com/Article/T9/78.aspx
璇誨彇緗戦〉鐨勫唴瀹瑰彲浠ョ被姣旀湰鍦扮殑鏂囦歡涓涓嬶紝浠g爜濡備笅錛?br>#include   <afxinet.h>
CString url;
    GetDlgItemText(IDC_EDIT1,url);
    CInternetSession Sess;
    CHttpFile
* cFile = (CHttpFile*)Sess.OpenURL(url,1,INTERNET_FLAG_TRANSFER_ASCII||INTERNET_FLAG_RELOAD,NULL,0);
    
    DWORD dwStatusCode;
    cFile
->QueryInfoStatusCode(dwStatusCode);
    
if(dwStatusCode == HTTP_STATUS_OK)
    
{
        CString szData,szAllData;
        
while(cFile->ReadString(szData))
        
{
            szAllData 
+= szData;
            szAllData 
+= "\r\n";
        }

        
        cFile
->Close();
        Sess.Close();
        CString name 
;
        name 
= "sd.htm";
        CFile file(name, CFile::modeCreate 
| CFile::modeWrite);
        file.Write(szAllData,szAllData.GetLength());
        file.Close();
    }

    
else
    
{
        MessageBox(
"璇鋒眰澶辮觸銆傘傘傘?/span>");
    }

鐢–InternetSession鎵撳紑url寰楀埌涓涓狢HttpFile錛岀敤ReadString璇誨彇CHttpFile涓殑鍐呭銆?br>

婕傛紓 2010-06-16 18:03 鍙戣〃璇勮
]]>
vc涓嚑涓簮浠g爜緗戠珯http://www.shnenglu.com/AutomateProgram/archive/2010/06/04/117176.html婕傛紓婕傛紓Fri, 04 Jun 2010 09:34:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/06/04/117176.htmlhttp://www.shnenglu.com/AutomateProgram/comments/117176.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/06/04/117176.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/117176.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/117176.htmlhttp://www.codefans.net/
婧愮爜緗戯細http://www.51kyuan.com/
vc椹跨珯錛?a >http://www.cctry.com/
hellocpp涓浗鐨刢odeproject錛?a >http://www.hellocpp.net/
紼嬪簭鍛樺皬杈夛細http://www.xiaohui.com/dev/
婧愮爜鎼滄悳錛?a >http://www.codesoso.com/default.aspx
涓浗榛戝錛?a >http://www.hackchina.com/

婕傛紓 2010-06-04 17:34 鍙戣〃璇勮
]]>
P2P鍘熺悊鐨勮В閲婁笌瀹炵幇http://www.shnenglu.com/AutomateProgram/archive/2010/03/29/110785.html婕傛紓婕傛紓Mon, 29 Mar 2010 01:05:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/29/110785.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110785.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/29/110785.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110785.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110785.htmlhttp://www.shnenglu.com/converse/archive/2006/09/02/11969.html
鍏充簬閲囩敤UDP鍗忚榪涜鎵撴礊浠ヨ繘琛孭2P浼氳瘽鐨勫師鐞?鎴戞湰鏉ユ兂鍐欎竴綃囨枃绔犱綔璇存槑,浣嗘槸鐜板湪宸茬粡鏈変竴綃囨枃绔犳妸鍘熺悊鎬х殑涓滆タ瑙i噴娓呮浜?鎴戝湪榪欓噷涓嶅啀浣滆繖閮ㄥ垎鐨勯噸澶?鍙互鍙傝榪欓噷:
P2P 涔?UDP絀塊廚AT鐨勫師鐞嗕笌瀹炵幇錛堥檮婧愪唬鐮侊級--http://www.cnpaf.net/Class/hack/0512182034513804825.htm

涓嬮潰瑙i噴涓涓嬩笂闈㈢殑鏂囩珷涓病鏈夋彁鍙婃垨鑰呰鎴戣寰楁瘮杈冩瑺緙虹殑鍦版柟.
縐佹湁鍦板潃/绔彛鍜屽叕鏈夊湴鍧/绔彛:鎴戜滑鐭ラ亾,鐜板湪澶ч儴鍒嗙綉緇滈噰鐢ㄧ殑閮芥槸NAPT(Network Address/Port Translator)浜?榪欎釜涓滀笢鐨勪綔鐢ㄦ槸涓涓澶栫殑瀵硅瘽鍦ㄧ粡榪嘚AT涔嬪悗IP鍦板潃鍜岀鍙e彿閮戒細琚敼鍐?鍦ㄨ繖閲屾妸涓嬈′細璇濅腑瀹㈡埛鑷繁璁や負鍦ㄤ嬌鐢ㄧ殑IP鍦板潃鍜岀鍙e彿鎴愪負縐佹湁鍦板潃/绔彛,鑰屾妸緇忚繃NAPT涔嬪悗琚敼鍐欑殑IP鍦板潃鍜岀鍙e彿縐頒負鍏湁鍦板潃/绔彛.鎴栬呭彲浠ヨ繖涔堢悊瑙?縐佹湁鍦板潃/绔彛鏄綘瀹墮噷浜哄浣犵殑鏄電О鑰屽叕鏈夊湴鍧/绔彛鍒欐槸浣犵湡姝e澶栧叕寮鐨勫悕瀛?濡備綍鑾峰緱鐢ㄦ埛鐨勭鐢ㄥ湴鍧/绔彛鍙?榪欎釜寰堢畝鍗曚簡,鑰岃寰楀埌鍏湁鍦板潃/绔彛鍙峰氨瑕佸湪榪炴帴涓婂彟涓鍙版満鍣ㄤ箣鍚庣敱閭e彴鏈哄櫒鐪嬪埌鐨処P鍦板潃鍜岀鍙e彿鏉ヨ〃紺?

濡傛灉鏄庣櫧浜嗕笂闈㈢殑涓滆タ,涓嬮潰榪涘叆鎴戜滑鐨勪唬鐮?鍦ㄨ繖閲岃В閲婁竴涓嬪叧閿儴鍒嗙殑瀹炵幇:

瀹㈡埛绔鍏堝緱鍒拌嚜宸辯殑縐佹湁鍦板潃/緇堢,鐒跺悗鍚憇erver绔彂閫佺櫥闄嗚姹?server绔湪寰楀埌榪欎釜璇鋒眰涔嬪悗灝卞彲浠ョ煡閬撹繖涓猚lient绔殑鍏湁鍦板潃/緇堢,server浼氫負姣忎竴涓櫥闄嗙殑client淇濆瓨瀹冧滑鐨勭鏈夊湴鍧/绔彛鍜屽叕鏈夊湴鍧/绔彛.

OK,涓嬮潰寮濮嬪叧閿殑鎵撴礊嫻佺▼.鍋囪client A瑕佸悜client B瀵硅瘽,浣嗘槸A涓嶇煡閬揃鐨勫湴鍧,鍗充嬌鐭ラ亾鏍規(guī)嵁NAT鐨勫師鐞嗚繖涓璇濆湪絎竴嬈′細琚嫆緇?鍥犱負client B鐨凬AT璁や負榪欐槸涓涓粠娌℃湁榪囩殑澶栭儴鍙戞潵鐨勮姹?榪欎釜鏃跺?A濡傛灉鍙戠幇鑷繁娌℃湁淇濆瓨B鐨勫湴鍧,鎴栬呰鍙戦佺粰B鐨勪細璇濊姹傚け璐ヤ簡,瀹冧細瑕佹眰server绔B鍚慉鎵撲竴涓礊,榪欎釜B->A鐨勪細璇濇剰涔夊湪浜庡畠浣縉AT B璁や負A鐨勫湴鍧/绔彛鏄彲浠ラ氳繃鐨勫湴鍧/绔彛,榪欐牱A鍐嶅悜B(tài)鍙戦佸璇濈殑鏃跺欏氨涓嶄細鍐嶈NAT B鎷掔粷浜?鎵撲竴涓瘮鏂規(guī)潵璇存槑鎵撴礊鐨勮繃紼?A鎯蟲潵B瀹跺仛瀹?浣嗘槸閬埌浜咮鐨勭瀹禢AT B鐨勬嫆緇?鐞嗙敱鏄?鎴戜粠鏉ユ病鏈夊惉鎴戝B鎻愯繃浣犵殑鍚嶅瓧,榪欐椂A鎵懼埌浜咥,B閮借璇嗙殑鏈嬪弸server,瑕佹眰server緇橞鎶ヤ竴涓俊,璁〣鍘昏窡綆″璇碅鏄垜鐨勬湅鍙?浜庢槸,B璺熺瀹禢AT B璇?A鏄垜璁よ瘑鐨勬湅鍙?榪欐牱A鐨勮闂姹傚氨涓嶄細鍐嶈綆″NAT B鎵鎷掔粷浜?綆鑰岃█涔?UDP鎵撴礊灝辨槸涓涓氳繃server淇濆瓨涓嬫潵鐨勫湴鍧浣垮緱褰兼涔嬮棿鑳藉鐩存帴閫氫俊鐨勮繃紼?server鍙甯姪寤虹珛榪炴帴,鍦ㄥ緩绔嬮棿鎺ヤ箣鍚庡氨涓嶅啀浠嬪叆浜?

濂戒簡,鍘熺悊鎬х殑涓滆タ瑙i噴鍒拌繖閲?闄勪歡涓湁涓涓畬鏁寸殑P2P婕旂ず紼嬪簭,鍛戒護琛屾ā寮忎笅,鍖呮嫭server绔拰client绔?鍦ㄨ繍琛岀殑鏃跺欓鍏堝惎鍔╯erver绔?鐒跺悗鎵撳紑鍑犱釜client绔垎鍒櫥闄?涔嬪悗褰兼涔嬮棿灝卞彲浠ョ浉浜掗氫俊浜?紼嬪簭鍦ㄦ湰鏈轟笂嫻嬭瘯閫氳繃,涔熷氨鏄祴璇曠殑鐜server鍜宑lient閮芥槸涓鍙版満鍣?榪樻病鏈夊湪涓嶅悓鐨勬満鍣ㄤ笂嫻嬭瘯榪?涓嶇煡閬撲細涓嶄細鏈夐棶棰?)
涓嬭澆鍦板潃:
http://www.shnenglu.com/Files/converse/P2PDemo.rar
鍙傝冭祫鏂?
1)P2P 涔?UDP絀塊廚AT鐨勫師鐞嗕笌瀹炵幇錛堥檮婧愪唬鐮侊級-http://www.cnpaf.net/Class/hack/0512182034513804825.htm
2)鐜嬭壋騫?lt;<Windows緗戠粶涓庨氫俊紼嬪簭璁捐>>


婕傛紓 2010-03-29 09:05 鍙戣〃璇勮
]]>
C++ TCP htons INADDR_ANY SOCKADDR_IN緇撴瀯http://www.shnenglu.com/AutomateProgram/archive/2010/03/28/110720.html婕傛紓婕傛紓Sun, 28 Mar 2010 02:44:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/28/110720.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110720.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/28/110720.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110720.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110720.html

1 htons

htons(1986)寰楀埌鐨勭粨鏋滄槸49671
濡備綍寰楀埌49671榪欎釜緇撴灉鍛?
1986杞崲鎴?6榪涘埗鏄?7C2
涓繪満欏哄簭杞崲鎴愮綉緇滈『搴忎箣鍚庢槸C207
C207杞崲涓哄崄榪涘埗鏄?9671
渚嬪瓙:0x12 34 56 78緇忚繃htons鏄?x78 56 34 12
鍦ㄧ粰SOCKADDR_IN緇撴瀯涓殑绔彛鍙風洿鎺ヨ祴鍊?瀹㈡埛绔拰鏈嶅姟绔叏閮ㄩ兘鐩存帴璧嬪?br style="line-height: 22px; ">SOCKADDR_IN addrSrv;   
addrSrv.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
addrSrv.sin_family = AF_INET;
addrSrv.sin_port = 1986;
榪欐牱涔熷彲浠ラ氳,浣嗙粦瀹氱殑绔彛鍙峰凡緇忎笉鏄?986,鑰屾槸49671

2 INADDR_ANY
#define INADDR_ANY  (u_long)0x00000000
INADDR_ANY琛ㄧず 鎵鏈夌殑IP,濡傛灉鑷繁鐨勪富鏈烘湁澶氫釜IP,鍦ㄧ粰SOCKADDR_IN 緇撴瀯鐨処P鍦板潃璧嬪兼椂灝辯敤INADDR_ANY.
濡傛灉鍙湁涓涓狪P涓旀槸鍥哄畾鐨?涔熷彲浠ヤ笉鐢↖NADDR_ANY,浣跨敤濡備笅璇彞
addrSrv.sin_addr.S_un.S_addr = inet_addr("221.217.218.111");
inet_addr鍑芥暟鏄皢涓涓偣鍒嗗崄榪涘埗鐨処P杞崲鎴愭棤絎﹀彿闀挎暣鍨?/p>

3 SOCKADDR_IN緇撴瀯
struct sockaddr_in
 {
    short   sin_family;
    u_short sin_port;
    struct  in_addr sin_addr;
    char    sin_zero[8];
};
sin_family:緗戠粶綾誨瀷
sin_port:緗戠粶绔彛鍙?br style="line-height: 22px; ">in_addr:IP鍦板潃
sin_zero:淇濊瘉緇撴瀯鐨勫ぇ灝?br style="line-height: 22px; ">in_addr鐨勭粨鏋勪負
struct in_addr {
        union {
                struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
                struct { u_short s_w1,s_w2; } S_un_w;
                u_long S_addr;
        } S_un;

瀵逛簬IP鍦板潃涓?21.217.218.111,addrSrv.sin_addr.S_un鐨勮祴鍊兼柟娉曞涓?br style="line-height: 22px; ">絎竴縐?
addrSrv.sin_addr.S_un.S_addr =111<<24|218<<16|217<<8|221;
絎簩縐?
addrSrv.sin_addr.S_un.S_addr =htonl(221<<24|217<<16|218<<8|111);
絎笁縐?
addrSrv.sin_addr.S_un.S_addr = inet_addr("221.217.218.111");
絎洓縐?
addrSrv.sin_addr .S_un.S_un_w.s_w1 =217<<8|221;
addrSrv.sin_addr .S_un.S_un_w.s_w2 =111<<8|218;
絎簲縐?
addrSrv.sin_addr .S_un.S_un_b.s_b1=221;
addrSrv.sin_addr .S_un.S_un_b.s_b2=217;
addrSrv.sin_addr .S_un.S_un_b.s_b3=218;
addrSrv.sin_addr .S_un.S_un_b.s_b4=111;



婕傛紓 2010-03-28 10:44 鍙戣〃璇勮
]]>
鐩存帴鐢╯ocket瀹屾垚HTTP涓嬭澆錛堣漿錛?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110666.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sat, 27 Mar 2010 04:39:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110666.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/110666.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110666.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/110666.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/110666.html</trackback:ping><description><![CDATA[鍘熸枃鍦板潃錛?a >http://www.cnoffice.info/Program/VC/VCnet/Program_55135.html</a> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/110666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-27 12:39 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110666.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>http 涓嬭澆http://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110662.html婕傛紓婕傛紓Sat, 27 Mar 2010 03:01:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110662.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110662.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/27/110662.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110662.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110662.htmlvisual c++緗戠粶閫氳緙栫▼瀹炵敤妗堜緥綺鵑変腑

 DWORD dwFlags;
 InternetGetConnectedState(&dwFlags, 0);
 CHAR strAgent[64];
 sprintf(strAgent, "Agent%ld", timeGetTime());
 HINTERNET hOpen;
 if(!(dwFlags & INTERNET_CONNECTION_PROXY))
  hOpen = InternetOpenA(strAgent, INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY, NULL, NULL, 0);
 else
  hOpen = InternetOpenA(strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
 if(!hOpen)
 {
  AfxMessageBox("Internet榪炴帴閿欒!");
  return -1;
 }

 DWORD dwSize;
 CHAR   szHead[] = "Accept: */*\r\n\r\n";
 VOID* szTemp[16384];
 HINTERNET  hConnect;
 CFile file;

 if ( !(hConnect = InternetOpenUrlA ( hOpen, szUrl, szHead,
   lstrlenA (szHead), INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_RELOAD, 0)))
 {
    AfxMessageBox("涓嶈兘鎵撳紑璇RL!");
    return -1;
 }

 if  (file.Open(szFileName,CFile::modeWrite|CFile::modeCreate)==FALSE )
 {
    AfxMessageBox("涓嶈兘鎵撳紑鏈湴鐨勬枃浠?");
   return -1;
 }

 DWORD dwByteToRead = 0;
 DWORD dwSizeOfRq = 4;
 DWORD dwBytes = 0;

    if (!HttpQueryInfo(hConnect, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER,
                  (LPVOID)&dwByteToRead, &dwSizeOfRq, NULL))
 {
  dwByteToRead = 0;
 }

 DWORD start;
 DWORD end;
 DWORD time;
 CString tempstring;
 time = 10;
 start = timeGetTime();
 do
 {
  if (!InternetReadFile (hConnect, szTemp, 16384,  &dwSize))
  {
   AfxMessageBox("璇繪枃浠跺嚭閿?");
   file.Close();
   return -1;
  }
  if (dwSize==0)
   break;
  else
   file.Write(szTemp,dwSize);
  dwBytes+=dwSize;
  if(dwByteToRead)
  {
   tempstring.Format("%d%%",(dwBytes*100)/dwByteToRead);
   SetDlgItemText(IDC_PERCENT_TEXT,tempstring);
  }
  FLOAT fSpeed = 0;
  fSpeed = (float)dwBytes;
  fSpeed /= ((float)time)/1000.0f;
  fSpeed /= 1024.0f;
  tempstring.Format("%dKB/s",fSpeed);
  SetDlgItemText(IDC_SPEED_TEXT,tempstring);
  end = timeGetTime();
  time = end - start;
  if(time == 0)
   time = 10;
 }while (TRUE);

 file.Close();
 InternetCloseHandle(hOpen);



婕傛紓 2010-03-27 11:01 鍙戣〃璇勮
]]>
WinINet鎿嶄綔嫻佺▼http://www.shnenglu.com/AutomateProgram/archive/2010/03/26/110569.html婕傛紓婕傛紓Fri, 26 Mar 2010 01:22:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/26/110569.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110569.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/26/110569.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110569.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110569.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/li_guotao/archive/2009/03/04/3956067.aspx
涓 WinINet鏄共浠涔堢殑錛?br>浜?濡傛灉瀹屾垚涓涓熀鏈殑WinINet鎿嶄綔嫻佺▼
涓?濡備綍寮傛瀹屾垚錛屽紓姝ユ搷浣滅殑濂藉銆?br>鍥?unicode浠ュ強mutilbyte
浜?浠g爜鏍蜂緥

涓 WinINet鏄井杞紑鍙戠殑涓涓簱錛屽彲浠ュ畬鎴恏ttp ftp瀹㈡埛绔殑宸ヤ綔銆傝紼嬪簭鍛樹粠澶嶆潅鐨勫崗璁腑鑺傜渷澶ч噺浣撳姏銆?/p>

浜?鎴戜細鐢ㄤ簡http, ftp綾諱技銆傜敤WinINet瀹屾垚涓涓猦ttp涓嬭澆闇瑕佷互涓嬫楠?銆?涓嬮潰榪欎釜鏄悓姝ユ搷浣滐紙涔熷氨鏄竴姝ユ鎿嶄綔錛屾瘡涓嚱鏁版墽琛屽畬鎵嶄細榪斿洖涓涓粨鏋滅殑鎰忔濓級

     1   InternetOpen      Initializes an application's use of the WinINet functions.
                   闇瑕佺殑璇?InternetSetOption 璁劇疆浠g悊鏈嶅姟鍣ㄥ湴鍧浠ュ強绔彛銆?br>                   http錛?nbsp;   ip:port 鎴栬?http=http://ip:port
                   socks錛歋OCKS=ip:port
     2   InternetConnect    鍏寵仈鐩爣鍦板潃鎴栬呭煙鍚嶄互鍙婃湇鍔p

     3   HttpOpenRequest   鍏寵仈瑕佷笅杞界殑鍐呭鍚嶅瓧
                   InternetSetOption 璁劇疆鐢ㄦ埛鍚嶅瘑鐮?/p>

     4   HttpSendRequest     榪欐灝辨槸鐢℉ttpOpenRequest 鐨勮繑鍥炲鹼紙宸茬粡鍏寵仈浜嗕笂闈㈢殑鎵鏈変俊鎭級鍙戦佸嚭鍘伙紝絎竴嬈$敤浜嗙綉緇溿傚悜鐩爣鏈嶅姟鍣ㄦ垨鑰呬唬鐞嗘湇鍔″櫒銆?/p>

     5   HttpQueryInfo
            璇ュ嚱鏁版煡璇㈣繑鍥炲鹼紝涓嶅弬涓庣綉緇滄搷浣溿傚彲浠ユ煡璇㈡湇鍔″櫒鐨勮繑鍥炰俊鎭紝姣斿鐩爣鏂囦歡鐨勫ぇ灝忥紝璇ユ枃浠舵槸鍚﹀瓨鍦紝浠g悊鏈嶅姟榪斿洖浜嗚姹傜敤鎴峰悕錛屽瘑鐮佺瓑絳夛紙榪欏嚑涓渶甯哥敤錛夛紝榪樻湁寰堝淇℃伅銆?/p>

     6   InternetReadFile
            寰堟櫘閫氱殑璇誨嚱鏁幫紝灝辨槸涓嬭澆鏂囦歡銆備笉鐭ラ亾鏄惁鍜屽簳灞傜綉緇滃悓姝ワ紝搴曞眰浼氫笉浼氭彁鍓嶄笅杞藉憿錛?/p>

     7   InternetCloseHandle 閲婃斁璧勬簮

涓?nbsp;   寮傛鎿嶄綔錛屾瘮杈冨鏉傜殑銆?nbsp;  涓轟粈涔堥渶瑕佸紓姝ユ搷浣滃憿錛?鍥犱負娑夊強鍒扮綉緇滄搷浣滐紝鏌愪簺鍑芥暟鍦ㄦ搷浣滀腑鍙兘闇瑕佹椂闂達紝濡傛灉涓鐩翠笉榪斿洖錛堟瘮濡?縐掞級鏃訛紝榪欐椂涓葷嚎紼嬭緇撴潫紼嬪簭錛屽矀涓嶅氨鍑虹幇鎰忔兂涓嶅埌鐨勭粨鏋滀簡錛屼絾鏄鏋滄瘡涓嚱鏁伴兘鑳藉鐬棿榪斿洖錛岀劧鍚庨氳繃WaitForMultipleObjects鎴栬匴aitForSingleObject絳夊緟緇撴灉鐨勫嚭鐜幫紙姝ゆ椂灝變笉浼氭搷浣滈偅涓秷鑰?縐掔殑鍑芥暟浜嗭紝鑰岃繖涓?縐掑嚱鏁版鏄鐢ㄥ埌緋葷粺璧勬簮HINTERNET鐨勶級銆?/p>

       寮傛鎿嶄綔鐨勭洰鐨勪笂濡傦紝鍘熺悊鍛紵 鍏跺疄鍘熺悊灝辨槸娉ㄥ唽涓涓嚱鏁幫紝鍦ㄨ繖閲屽彨InternetStatusCallback錛屽洜涓哄井杞啓寰楀簳灞備唬鐮佽鐢ㄥ埌錛屾墍浠ュ繀欏繪牸寮忕粺涓銆備竴鏃︽湁緇撴灉鏉ヤ簡灝遍氳繃浜嬩歡閫氱煡鎴戜滑錛學aitForSingleObject鍑芥暟灝卞彲浠ヨ蛋浜嗐傛瘮濡傜瓑鍒頒簡HINTERNET鍒涘緩鎴栬呭懡浠ゅ彂閫佹垚鍔熺瓑緇撴灉銆傜劧鍚庢垜浠氨鍙互絎竴鏃墮棿瀹夊叏鐨勪嬌鐢ㄤ簡銆?br>      API 鍑芥暟濡傛灉鍚嶅瓧鏈鍚庡彲浠ュ甫EX錛岄偅涔堝甫ex鐨勫氨鏄紓姝ユ搷浣滅殑銆?/p>

鍥?涓瀹氳娉ㄦ剰錛屽嚒鏄湁unicode鍜宮utilbyte鍑芥暟鐨勪竴瀹氳緇熶竴錛屾渶濂介兘鐢╩utilbyte鐨勩?/p>


浜旓細 浠g爜濡備笅錛?br>// crt_assert.c
// compile with: /c
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>


#include <iostream>

#include "winsock2.h"
#include <string>
#include <Wininet.h>
#include <windows.h>
#include <fstream>銆//瑕佷嬌鐢ㄦ枃浠惰緭鍏ヨ緭鍑烘祦蹇呴』鐨勫ご鏂囦歡
using namespace std;
#define __HTTP_VERB_GET    "GET"
#define __HTTP_VERB_POST "POST"
#define __HTTP_ACCEPT_TYPE "*/*"
#define __HTTP_ACCEPT "Accept: */*\r\n"
#define __SIZE_HTTP_BUFFER    100000
#define __SIZE_HTTP_RESPONSE_BUFFER    100000
#define __SIZE_HTTP_HEAD_LINE    2048

void CALLBACK InternetStatusCallback(

                                    HINTERNET hInternet,
                                    DWORD dwContext,
                                    DWORD dwInternetStatus,
                                    LPVOID lpvStatusInformation,
                                    DWORD dwStatusInformationLength);
HANDLE hEvent[3];

HINTERNET hFile;
HINTERNET hNet;
HINTERNET hSession,hConnect,hRequest;
int WaitExitEvent()
{
    //return 1;
    DWORD dwRet = ::WaitForMultipleObjects(3, hEvent, FALSE, 30000);//INFINITE);
    int x=-1;
    switch (dwRet)
    {
        //鍙ユ焺琚垱寤轟簨浠舵垨鑰呰鏁版嵁璇鋒眰鎴愬姛瀹屾垚浜嬩歡
    case WAIT_OBJECT_0:
        x=0;
        cout<<"WAIT_OBJECT_0"<<endl;
        //鍙ユ焺琚叧闂簨浠?br>        break;
    case WAIT_OBJECT_0+1:
        x=1;
        cout<<"WAIT_OBJECT_1"<<endl;
        //鐢ㄦ埛瑕佹眰緇堟瀛愮嚎紼嬩簨浠舵垨鑰呭彂鐢熼敊璇簨浠?br>        break;
    case WAIT_OBJECT_0+2:
        x=2;
        cout<<"WAIT_OBJECT_2"<<endl;
       
        break;
    default:
        cout<<"WaitForMultipleObjects time out"<<endl;
        return -1;

    }
    return x;
}

// 鏀寔浠g悊璁劇疆錛?鏄惁寮傛璁劇疆錛?閲囩敤浜嬩歡椹卞姩
void WinINet3(bool setProxy, bool ASYNC)
{
    hSession=NULL;
    hConnect=NULL;
    hRequest=NULL;
    for (int i = 0; i < 3; i++)
    {
        hEvent[i] = CreateEvent(
            NULL,   // default security attributes
            FALSE, // auto-reset event object
            FALSE, // initial state is nonsignaled
            NULL); // unnamed object

        if (hEvent[i] == NULL)
        {
            printf("CreateEvent error: %d\n", GetLastError() );
            ExitProcess(0);
        }
    }
    char *url = "    char *pip = "down.360safe.com";
    char *paim = "/setup.exe";

 

    //   step 1
    if(ASYNC)    cout<<"寮傛妯″紡"<<endl;
   // setProxy =false;
    if(setProxy)
    {
        cout<<"浠g悊妯″紡"<<endl;
        if(ASYNC)
          hSession = InternetOpen("name",
        INTERNET_OPEN_TYPE_DIRECT,//|INTERNET_OPEN_TYPE_PROXY,// INTERNET_OPEN_TYPE_PROXY,
        NULL,NULL,INTERNET_FLAG_ASYNC); // 寮傛
        else
          hSession = InternetOpen("name",INTERNET_OPEN_TYPE_PROXY,NULL,NULL,0); // 鍚屾
    }
    else
    {
        if(ASYNC)
            hSession = InternetOpen("name",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,INTERNET_FLAG_ASYNC); // 寮傛
        else
            hSession = InternetOpen("name",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); // 鍚屾
    }
    if(!hSession){
        DWORD er = ::GetLastError();
        cout<<"InternetOpen error"<<endl;//, "Err", MB_OK);
        return;
    }
    if(ASYNC)
    {
        //Sleep(500);
        INTERNET_STATUS_CALLBACK res = ::InternetSetStatusCallback(hSession,InternetStatusCallback);
        if(res == INTERNET_INVALID_STATUS_CALLBACK)
        {
            cout<<"InternetSetStatusCallback failed, so return "<<endl;
            return ;   
        }
        else
        {
            cout<<"InternetSetStatusCallback succeed, so go on "<<endl;

        }
        //Sleep(500);
    }
   
    char   strProxyList[MAX_PATH],   strUsername[64],   strPassword[64];
    strcpy(strProxyList,   "SOCKS=58.56.87.2:1080"); //   鍐欎笂socks鎬庝箞灝辨棤鏁堜簡鍛紵錛燂紵SOCKS5=172.18.132.27:1080
    strcpy(strUsername,   "user01");
    strcpy(strPassword,   "baidu");
    INTERNET_PROXY_INFO proxy;
    proxy.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
    proxy.lpszProxy    = strProxyList;
    proxy.lpszProxyBypass = NULL;
    if( setProxy &&!InternetSetOption(hSession,INTERNET_OPTION_PROXY ,&proxy,sizeof(INTERNET_PROXY_INFO)))
    {
        cout<<"InternetSetOption failed"<<endl;
        return ;
    }
   
    // step 2
    //濡傛灉鏄庣‘鐭ラ亾闇瑕佽璇侊紝絎?錛?涓弬鏁板彲浠ヨ緭鍏ョ敤鎴峰悕錛屽瘑鐮?administrator","password"
    //絎?錛?涓弬鏁頒負鐩爣涓繪満IP銆佺鍙e彿(涓嶆槸浠g悊鏈嶅姟鍣ㄧ殑鍙傛暟)
    hConnect = InternetConnect(hSession,pip,INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,INTERNET_SERVICE_HTTP,INTERNET_FLAG_RELOAD,0);
    if(!ASYNC &&!hConnect){
        cout<<"鍚屾錛孖nternetConnect error"<<endl;//, "Err", MB_OK);
        return;
    }
    if( ASYNC&& hConnect== NULL)// 寮傛 闇瑕佺瓑寰?nbsp;  绔熺劧鐩存帴鍒涘緩濂戒簡
    {
        int er = GetLastError();
        DWORD dwError = ::GetLastError();
        if (dwError != ERROR_IO_PENDING)
        {
            cout<<"CHttpDownload::OpenInternetConnection| 榪炴帴澶辮觸" <<endl;
            return ;
        }
        else //
        {
            cout<<"hConnect == NULL, so run WaitExitEvent"<<endl;
            WaitExitEvent(); // 絳夊緟鎴愬姛鍒涘緩 // 榪欓噷搴旇絳夊緟   榪欓噷搴旇鏄劇ず涓嬈″憖
            ::ResetEvent(hEvent[0]);
            ::ResetEvent(hEvent[1]);
            ::ResetEvent(hEvent[2]);
        }
    }
    cout<<"step 2 :InternetConnect secced"<<endl;

    // ::InternetSetStatusCallback(hConnect,InternetStatusCallback);
   
    // step 3!!!
    char   szHead[] = "Accept: */*\r\n\r\n";
    char **p = new char*[2];*p = szHead;*(p+1) = NULL;

    //hRequest = HttpOpenRequest(hConnect,"GET","download/BaiduHi_1.0_Beta2.exe",NULL,NULL,/*(const char **)p*/NULL,0/*INTERNET_FLAG_NO_COOKIES|INTERNET_FLAG_RELOAD*/,0); // no request;
    CONST TCHAR *szAcceptType=__HTTP_ACCEPT_TYPE;
    hRequest = ::HttpOpenRequest(hConnect,
        "GET",
        paim,
        HTTP_VERSION,
        "",
        &szAcceptType,
        INTERNET_FLAG_RELOAD|INTERNET_FLAG_KEEP_CONNECTION|INTERNET_FLAG_NO_CACHE_WRITE,
        0);
   
    //::HttpAddRequestHeaders( hRequest, __HTTP_ACCEPT, strlen(__HTTP_ACCEPT), HTTP_ADDREQ_FLAG_REPLACE);
    /*_hHTTPRequest=::HttpOpenRequest(    _hHTTPConnection,
        __HTTP_VERB_GET, // HTTP Verb
        szURI, // Object Name
        HTTP_VERSION, // Version
        "", // Reference
        &szAcceptType, // Accept Type
        INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE,
        0); // context call-back point
    */
    if (!ASYNC&& !hRequest){
        cout<<"鍚屾錛孒ttpOpenRequest error"<<endl;//, "Err", MB_OK);
        return;
    }
    if( ASYNC&& hRequest== NULL)// 寮傛 闇瑕佺瓑寰?br>    {
        int er = GetLastError();
        DWORD dwError = ::GetLastError();
        if (dwError != ERROR_IO_PENDING)
        {
            cout<<"CHttpDownload::OpenInternetConnection| 榪炴帴澶辮觸" <<endl;
            return ;
        }
        else //
        {
            cout<<"hRequest == NULL, so run WaitExitEvent"<<endl;
            WaitExitEvent(); // 絳夊緟鎴愬姛鍒涘緩
            ::ResetEvent(hEvent[0]);
            ::ResetEvent(hEvent[1]);
            ::ResetEvent(hEvent[2]);
        }
    }
    //Sleep(10000);
    cout << "step 3 : HttpOpenRequest success"<<endl;
    //::InternetSetStatusCallback(hRequest,InternetStatusCallback);
    //////////////////////////////////////////////
    if (setProxy )
    {
        // InternetSetOption 涓嶈寮傛絳夊緟
        if( !InternetSetOption(hRequest,INTERNET_OPTION_PROXY_USERNAME ,strUsername,strlen(strUsername)+1))
        {
            cout<<"InternetSetOption Username failed"<<endl;
            return ;
        }
        if( !InternetSetOption(hRequest,INTERNET_OPTION_PROXY_PASSWORD ,strPassword,strlen(strPassword)+1))
        {
            cout<<"InternetSetOption Password failed"<<endl;
            return ;
        }
    }
    // step 4
    //HttpSendRequest(hRequest,NULL,0,NULL,0);
    //Sleep(3000);
    ::ResetEvent(hEvent[0]);
    ::ResetEvent(hEvent[1]);
    ::ResetEvent(hEvent[2]);
    if(!::HttpSendRequest(hRequest,NULL,0,NULL,0)) // 涓轟粈涔堝け璐ワ紵錛燂紵
    {
        //Sleep(3000);
        if(!ASYNC)// 鍚屾
        {
            DWORD dwError = ::GetLastError();
              cout<<"鍚屾錛孒ttpSendRequest failed, GetLastError=="<<dwError<<endl;
            return ;
       
        }
        else
        {
            Sleep(3000);
            DWORD dwError = ::GetLastError();
            cout<<"dwError =="<<dwError<<endl;
            if (dwError != ERROR_IO_PENDING)
            {
                cout<<"dwError != ERROR_IO_PENDING, so quit,dwError =="<<dwError<<endl;
                return ;
            }
            else //
            {
                cout<<"HttpSendRequest, so run WaitExitEvent"<<endl;
                Sleep(3000);
                //if(WaitExitEvent()!=2)//; // 絳夊緟鎴愬姛鍒涘緩 絳夊緟鏄惁涓嶅錛燂紵錛?br>                {
                       cout<<"had not recv complete event, so quit"<<endl;
                    // return ;
                }
            }
        }
       
    }
    Sleep(3000);
    cout << "step 4: HttpSendRequest success!"<<endl;

    int bufh[1000];
    DWORD dwLen,dwIndex;
    /*if(!::HttpQueryInfo(hRequest, HTTP_QUERY_RAW_HEADERS_CRLF, bufh, &dwLen, &dwIndex))// 榪欏彞璇濓紵錛燂紵
    {
        //return E_FAIL;
        return;
    }
*/
    // 鍒ゆ柇鐘舵佺爜錛?br>    char m_dwStatusCode[90];
    DWORD dwStatusSize = sizeof(m_dwStatusCode);
    /*if (FALSE == ::HttpQueryInfo(hRequest,   // 鏌ヨ澶辨晥錛燂紵
        HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
        &m_dwStatusCode,
        &dwStatusSize,
        NULL))   //鑾峰彇榪斿洖鐘舵佺爜
    {
        return ;
    }
    //鍒ゆ柇鐘舵佺爜鏄笉鏄?200
    //if (HTTP_STATUS_OK != m_dwStatusCode)
    {
        //return ;
    }
*/

    DWORD dwByteToRead = 0;
    DWORD dwSizeOfRq = 4;
    DWORD dwBytes = 0;
    //榪欎笁涓煎垎鍒瓨鍌ㄦ枃浠剁殑澶у皬錛孒ttpQueryInfo鍐呭鐨勫ぇ灝忓拰鎬誨叡璇誨彇鐨勫瓧鑺傛暟銆?br>    //HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwByteToRead, &dwSizeOfRq, NULL);
    //闇瑕佽鏄庣殑鏄?HttpQueryInfo 騫朵笉榪涜緗戠粶鎿嶄綔錛屽洜姝ゅ畠涓嶉渶瑕佽繘琛屽紓姝ユ搷浣滅殑澶勭悊銆?
    if (!HttpQueryInfo(hRequest, HTTP_QUERY_CONTENT_LENGTH | HTTP_QUERY_FLAG_NUMBER, (LPVOID)&dwByteToRead, &dwSizeOfRq, NULL))
    { // 榪欓噷澶辮觸浜嗭紵錛燂紵
       
        DWORD dwError = ::GetLastError();
        cout<<"HttpQueryInfo failed, so return錛?GetLastError() =="<<dwError<<endl;
        return ;
    }
    FILE * pFile = fopen("e://baidu01.exe", "wb" );
    //ofstream mfile("out.txt");//瀹氫箟鏂囦歡杈撳嚭嫻乷uf錛屽茍鍏寵仈鍒皁ut.txt
    int i=0;
    DWORD leftB = dwByteToRead;
    cout<<"寮濮嬩笅杞?<<endl;
    if( !ASYNC) // 鍚屾涓嬭澆
    {
        while(true)
        {
            const int MAX_BUFFER_SIZE = 65536;
            unsigned long nSize = 0;
            char szBuffer[MAX_BUFFER_SIZE+2];
            int num = MAX_BUFFER_SIZE;
            if( leftB < num);
            num = leftB;
            BOOL bRet = ::InternetReadFile(hRequest, szBuffer, num, &nSize); // 寮傛 闇瑕佺瓑寰?/p>

            leftB -= nSize;
            cout<<i++<<" size: "<<nSize<<endl;
            if(!bRet || nSize <= 0)
                break;
            fwrite(szBuffer, sizeof(char), nSize, pFile);
        }
    }
    else // 寮傛涓嬭澆
    {
        INTERNET_BUFFERS i_buf = {0};
        i_buf.dwStructSize = sizeof(INTERNET_BUFFERS);
        i_buf.lpvBuffer = new TCHAR[10242];
        i_buf.dwBufferLength = 10240;
         for( DWORD i=0;i<dwByteToRead;)
        {
            //閲嶇疆璇繪暟鎹簨浠?br>            ::ResetEvent( hEvent[0]);
            int num = 10240;
            if(dwByteToRead-i<10240)
            {
                num = dwByteToRead-i;
                   i_buf.dwBufferLength = dwByteToRead-i;
            }
            if (FALSE == ::InternetReadFileEx(hRequest,
                &i_buf,
                IRF_ASYNC,
                NULL))
            {
                if (ERROR_IO_PENDING == ::GetLastError())
                {
                    if ( NULL)//WaitExitEvent()!=2)
                    {
                        delete[] i_buf.lpvBuffer;
                        return ;
                    }
                }
                else
                {
                    cout<<"down failed,so return"<<endl;
                    delete[] i_buf.lpvBuffer;
                    return ;
                }
            }
            else
            {
                //鍦ㄧ綉緇滀紶杈撻熷害蹇紝姝ラ暱杈冨皬鐨勬儏鍐典笅錛?br>                //InternetReadFileEx 緇忓父浼氱洿鎺ヨ繑鍥炴垚鍔燂紝
                //鍥犳瑕佸垽鏂槸鍚﹀彂鐢熶簡鐢ㄦ埛瑕佹眰緇堟瀛愮嚎紼嬩簨浠躲?br>                cout<<"緗戠粶寰堝ソ錛孖nternetReadFileEx榪斿洖true"<<endl;

                // 鏆備笉鑰冭檻鐢ㄦ埛閫鍑?br>            }
            i += i_buf.dwBufferLength; // 鏈鍚庝竴嬈″啓澶氫簡錛侊紒錛?br>            fwrite(i_buf.lpvBuffer, sizeof(char), i_buf.dwBufferLength, pFile);
            cout<<"i== "<<i<<endl;
            //淇濆瓨鏁版嵁
             //閫氱煡涓葷嚎紼嬩笅杞借繘搴?br>                   
        }
    }
    InternetCloseHandle(hRequest);
    InternetCloseHandle(hConnect);
    InternetCloseHandle(hSession);
    cout<<"success download file"<<endl;
   
    return;
}

int main( void )
{
   
    WinINet3(true,true);
    return 1;
}

void OnInternetHandleCreated(HINTERNET hInternet, LPINTERNET_ASYNC_RESULT lpInetStatusResult)
{
    if(NULL == lpInetStatusResult)
    {
        //ATLASSERT( 0 );
        return;
    }
    hFile = HINTERNET(lpInetStatusResult->dwResult);
    HINTERNET    hInet = HINTERNET(lpInetStatusResult->dwResult);
    DWORD        dwInetHandleType;
    DWORD        dwTypeLen = sizeof(dwInetHandleType);

    InternetQueryOption( hInet, INTERNET_OPTION_HANDLE_TYPE, &dwInetHandleType, &dwTypeLen);
    switch(dwInetHandleType)
    {
    case INTERNET_HANDLE_TYPE_CONNECT_HTTP:
        //CloseInternetConnection(); //   榪欓噷鏄綍鎰忥紵錛燂紵錛?閫氳繃鍥炶皟 璁劇疆httpConnect
        hConnect = hInet;     //
        break;
    case INTERNET_HANDLE_TYPE_HTTP_REQUEST:
        //CloseInternetFile();    //    榪欓噷鏄綍鎰忥紵錛?nbsp;   閫氳繃鍥炶皟 璁劇疆httpFile
        hRequest = hInet;    //
        break;
    default:
        break;
    }
    cout<<"OnInternetHandleCreated, so ::SetEvent(hEvent[0])"<<endl;
    // HANDLE宸插垱寤轟簨浠訛紙寮傛鎺у埗錛?br>    ::SetEvent(hEvent[0]);
}
void OnInternetRequestComplete(HINTERNET hInternet, LPINTERNET_ASYNC_RESULT lpInetStatusResult)
{

    if( lpInetStatusResult == NULL )
    {
        //ATLASSERT( 0 );
        return;
    }
    cout<<"OnInternetRequestComplete, so ::SetEvent(hEvent[2])"<<endl;
    // 嬋鍙戣姹傚畬鎴愪簨浠訛紙寮傛鎺у埗錛?br>    ::SetEvent(hEvent[0]);
}

void CALLBACK InternetStatusCallback(
                                    HINTERNET hInternet,
                                    DWORD_PTR dwContext,
                                    DWORD dwInternetStatus,
                                    LPVOID lpvStatusInformation,
                                    DWORD dwStatusInformationLength
                                    )
{
    cout<<"榪涘叆鍥炶皟"<<endl;
    switch (dwInternetStatus)
    {
    case INTERNET_STATUS_RESOLVING_NAME:
        break;
    case INTERNET_STATUS_NAME_RESOLVED:
        break;
    case INTERNET_STATUS_CONNECTING_TO_SERVER:
        break;
    case INTERNET_STATUS_CONNECTED_TO_SERVER:
        break;
    case INTERNET_STATUS_SENDING_REQUEST:
        break;
    case INTERNET_STATUS_REQUEST_SENT:
        break;
    case INTERNET_STATUS_RECEIVING_RESPONSE:
        break;
    case INTERNET_STATUS_RESPONSE_RECEIVED:
        break;
    case INTERNET_STATUS_CLOSING_CONNECTION:
        break;
    case INTERNET_STATUS_CONNECTION_CLOSED:
        break;
    case INTERNET_STATUS_HANDLE_CREATED:
        cout<<"鍥炶皟鏄疘NTERNET_STATUS_HANDLE_CREATED"<<endl;
        OnInternetHandleCreated(hInternet, LPINTERNET_ASYNC_RESULT(lpvStatusInformation)); // 浼犻掍簡HINTERNET 榪欐槸綺鵑珦鍛
        break;
    case INTERNET_STATUS_HANDLE_CLOSING:
        break;
    case INTERNET_STATUS_REQUEST_COMPLETE:
        cout<<"鍥炶皟鏄疘NTERNET_STATUS_REQUEST_COMPLETE"<<endl;
        OnInternetRequestComplete(hInternet, LPINTERNET_ASYNC_RESULT(lpvStatusInformation));
        break;
    case INTERNET_STATUS_REDIRECT:
    case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
    case INTERNET_STATUS_STATE_CHANGE:
    default:
        break;
    }
}



婕傛紓 2010-03-26 09:22 鍙戣〃璇勮
]]>
DrawFrameControl 緇樺埗鎺т歡http://www.shnenglu.com/AutomateProgram/archive/2010/03/23/110335.html婕傛紓婕傛紓Tue, 23 Mar 2010 02:36:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/23/110335.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110335.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/23/110335.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110335.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110335.htmlDrawFrameControl 鐨勬晥鏋滐細
RECT rect;
    rect.top = 0;
    rect.left = 0;
    rect.bottom = 40;    
    rect.right = 40;
    pDC->DrawFrameControl(&rect, DFC_CAPTION, DFCS_CAPTIONCLOSE);
    rect.left = 50;
    rect.right = 90;
    pDC->DrawFrameControl(&rect, DFC_CAPTION, DFCS_CAPTIONMIN);
    rect.left = 100;
    rect.right = 140;
    pDC->DrawFrameControl(&rect, DFC_CAPTION, DFCS_CAPTIONMAX);
    rect.left = 150;
    rect.right = 190;
    pDC->DrawFrameControl(&rect, DFC_CAPTION, DFCS_CAPTIONRESTORE);
    rect.left = 200;
    rect.right = 240;
    pDC->DrawFrameControl(&rect, DFC_CAPTION, DFCS_CAPTIONHELP);
 // TODO: Menu bar
    rect.left = 250;   
    rect.right = 290;
    pDC->DrawFrameControl(&rect, DFC_MENU, DFCS_MENUARROW);
    rect.left = 300;
    rect.right = 340;
    pDC->DrawFrameControl(&rect, DFC_MENU, DFCS_MENUCHECK);
    rect.left = 350;
    rect.right = 390;
    pDC->DrawFrameControl(&rect, DFC_MENU, DFCS_MENUBULLET);
    rect.left = 400;
    rect.right = 440;
    pDC->DrawFrameControl(&rect, DFC_MENU, DFCS_MENUARROWRIGHT);
 // TODO: Scroll bar
    rect.top = 50;
    rect.left = 0;
    rect.bottom = 90;    
    rect.right = 40;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLUP);
    rect.left = 50;
    rect.right = 90;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLDOWN);
    rect.left = 100;
    rect.right = 140;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLLEFT);
    rect.left = 150;
    rect.right = 190;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLRIGHT);
    rect.left = 200;
    rect.right = 240;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX);
    rect.left = 250;
    rect.right = 290;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
    rect.left = 300;
    rect.right = 340;
    pDC->DrawFrameControl(&rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIPRIGHT);
 // TODO: Standard button
    rect.top = 100;
    rect.left = 0;
    rect.bottom = 140;    
    rect.right = 40;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONCHECK);
    rect.left = 50;
    rect.right = 90;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONRADIOIMAGE);
    rect.left = 100;
    rect.right = 140;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONRADIOMASK);
    rect.left = 150;
    rect.right = 190;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONRADIO);
    rect.left = 200;
    rect.right = 240;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTON3STATE);
    rect.left = 250;
    rect.right = 290;
    pDC->DrawFrameControl(&rect, DFC_BUTTON, DFCS_BUTTONPUSH);

浣跨敤DrawFrameControl 瀹氬埗鑷繁鐨刢heck鎸夐挳
void CMyCheckButton::OnPaint()
{
 CPaintDC dc(this); // device context for painting
 CRect rect;
 GetClientRect(&rect);

 CRect BoxRect;
 BoxRect=rect;
 BoxRect.right =BoxRect.left +15;
 dc.DrawFrameControl(BoxRect,DFC_BUTTON,DFCS_BUTTONCHECK|GetCheck()?DFCS_CHECKED :0);

 CFont   myFont; 
 myFont.CreatePointFont (100,_T("瀹嬩綋"));
 CFont   *pOldFont=(CFont   *)dc.SelectObject(&myFont);
 dc.SetBkMode(TRANSPARENT);  

 CString StrWndText;
 GetWindowText(StrWndText);

 rect.OffsetRect (20,0);
 dc.SetTextColor(RGB(0,0,0));
 dc.DrawText(StrWndText,   rect,   DT_LEFT|DT_VCENTER|DT_SINGLELINE);
 dc.SelectObject   (pOldFont); 
 myFont.DeleteObject   (); 
}



婕傛紓 2010-03-23 10:36 鍙戣〃璇勮
]]>
CFile鎿嶄綔璇﹁Вhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/22/110281.html婕傛紓婕傛紓Mon, 22 Mar 2010 03:09:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/22/110281.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110281.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/22/110281.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110281.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110281.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/zhuang_rui/archive/2007/09/28/1804875.aspx
鍚勭鍏充簬鏂囦歡鐨勬搷浣滃湪紼嬪簭璁捐涓槸鍗佸垎甯歌錛屽鏋滆兘瀵瑰叾鍚勭鎿嶄綔閮戒簡濡傛寚鎺岋紝灝卞彲浠ユ牴鎹疄闄呮儏鍐墊壘鍒版渶浣崇殑瑙e喅鏂規(guī)錛屼粠鑰屽湪杈冪煭鐨勬椂闂村唴緙栧啓鍑洪珮鏁堢殑浠g爜錛屽洜鑰岀啛緇冪殑鎺屾彙鏂囦歡鎿嶄綔鏄崄鍒嗛噸瑕佺殑銆傛湰鏂囧皢瀵筕isual C++涓湁鍏蟲枃浠舵搷浣滆繘琛屽叏闈㈢殑浠嬬粛錛屽茍瀵瑰湪鏂囦歡鎿嶄綔涓粡甯擱亣鍒扮殑涓浜涚枒闅鵑棶棰樿繘琛岃緇嗙殑鍒嗘瀽銆?br>銆銆1錛庢枃浠剁殑鏌ユ壘
銆銆褰撳涓涓枃浠舵搷浣滄椂錛屽鏋滀笉鐭ラ亾璇ユ枃浠舵槸鍚﹀瓨鍦紝灝辮棣栧厛榪涜鏌ユ壘銆侻FC涓湁涓涓笓闂ㄧ敤鏉ヨ繘琛屾枃浠舵煡鎵劇殑綾籆FileFind錛屼嬌鐢ㄥ畠鍙互鏂逛究蹇嵎鍦拌繘琛屾枃浠剁殑鏌ユ壘銆備笅闈㈣繖孌典唬鐮佹紨紺轟簡榪欎釜綾葷殑鏈鍩烘湰浣跨敤鏂規(guī)硶銆?
銆銆CString strFileTitle;
銆銆CFileFind finder;
銆銆BOOL bWorking = finder.FindFile("C:\\windows\\sysbkup\\*.cab");
銆銆while(bWorking)
銆銆{
銆銆bWorking=finder.FindNextFile();
銆銆strFileTitle=finder.GetFileTitle();
銆銆}
銆銆2錛庢枃浠剁殑鎵撳紑/淇濆瓨瀵硅瘽妗?
銆銆璁╃敤鎴烽夋嫨鏂囦歡榪涜鎵撳紑鍜屽瓨鍌ㄦ搷浣滄椂錛屽氨瑕佺敤鍒版枃浠舵墦寮/淇濆瓨瀵硅瘽妗嗐侻FC鐨勭被CFileDialog鐢ㄤ簬瀹炵幇榪欑鍔熻兘銆備嬌鐢–FileDialog澹版槑涓涓璞℃椂錛岀涓涓狟OOL鍨嬪弬鏁扮敤浜庢寚瀹氭枃浠剁殑鎵撳紑鎴栦繚瀛橈紝褰撲負TRUE鏃跺皢鏋勯犱竴涓枃浠舵墦寮瀵硅瘽妗嗭紝涓篎ALSE鏃舵瀯閫犱竴涓枃浠朵繚瀛樺璇濇銆?
銆銆鍦ㄦ瀯閫燙FileDialog瀵硅薄鏃訛紝濡傛灉鍦ㄥ弬鏁頒腑鎸囧畾浜哋FN_ALLOWMULTISELECT椋庢牸錛屽垯鍦ㄦ瀵硅瘽妗嗕腑鍙互榪涜澶氶夋搷浣溿傛鏃惰閲嶇偣娉ㄦ剰涓烘CFileDialog瀵硅薄鐨刴_ofn.lpstrFile鍒嗛厤涓鍧楀唴瀛橈紝鐢ㄤ簬瀛樺偍澶氶夋搷浣滄墍榪斿洖鐨勬墍鏈夋枃浠惰礬寰勫悕錛屽鏋滀笉榪涜鍒嗛厤鎴栧垎閰嶇殑鍐呭瓨榪囧皬灝變細瀵艱嚧鎿嶄綔澶辮觸銆備笅闈㈣繖孌電▼搴忔紨紺轟簡鏂囦歡鎵撳紑瀵硅瘽妗嗙殑浣跨敤鏂規(guī)硶銆?
銆銆CFileDialog mFileDlg(TRUE,NULL,NULL,
銆銆OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,
銆銆"All Files (*.*)|*.*||",AfxGetMainWnd());
銆銆CString str(" ",10000);
銆銆mFileDlg.m_ofn.lpstrFile=str.GetBuffer(10000);
銆銆str.ReleaseBuffer();
銆銆POSITION mPos=mFileDlg.GetStartPosition();
銆銆CString pathName(" ",128);
銆銆CFileStatus status;
銆銆while(mPos!=NULL)
銆銆{
銆銆pathName=mFileDlg.GetNextPathName(mPos);
銆銆CFile::GetStatus( pathName, status );
銆銆}
銆銆3錛庢枃浠剁殑璇誨啓
銆銆鏂囦歡鐨勮鍐欓潪甯擱噸瑕侊紝涓嬮潰灝嗛噸鐐硅繘琛屼粙緇嶃傛枃浠惰鍐欑殑鏈鏅氱殑鏂規(guī)硶鏄洿鎺ヤ嬌鐢–File榪涜錛屽鏂囦歡鐨勮鍐欏彲浠ヤ嬌鐢ㄤ笅闈㈢殑鏂規(guī)硶錛?
銆銆//瀵規(guī)枃浠惰繘琛岃鎿嶄綔
銆銆char sRead[2];
銆銆CFile mFile(_T("user.txt"),CFile::modeRead);
銆銆if(mFile.GetLength()<2)
銆銆return;
銆銆mFile.Read(sRead,2);
銆銆mFile.Close();
銆銆//瀵規(guī)枃浠惰繘琛屽啓鎿嶄綔
銆銆CFile mFile(_T("user.txt "), CFile::modeWrite|CFile::modeCreate);
銆銆mFile.Write(sRead,2);
銆銆mFile.Flush();
銆銆mFile.Close();
銆銆铏界劧榪欑鏂規(guī)硶鏈涓哄熀鏈紝浣嗘槸瀹冪殑浣跨敤綣佺悙錛岃屼笖鍔熻兘闈炲父綆鍗曘傛垜鍚戜綘鎺ㄨ崘鐨勬槸浣跨敤CArchive錛屽畠鐨勪嬌鐢ㄦ柟娉曠畝鍗曚笖鍔熻兘鍗佸垎寮哄ぇ銆傞鍏堣繕鏄敤CFile澹版槑涓涓璞★紝鐒跺悗鐢ㄨ繖涓璞$殑鎸囬拡鍋氬弬鏁板0鏄庝竴涓狢Archive瀵硅薄錛屼綘灝卞彲浠ラ潪甯告柟渚垮湴瀛樺偍鍚勭澶嶆潅鐨勬暟鎹被鍨嬩簡銆傚畠鐨勪嬌鐢ㄦ柟娉曡涓嬩緥銆?
銆銆//瀵規(guī)枃浠惰繘琛屽啓鎿嶄綔
銆銆CString strTemp;
銆銆CFile mFile;
銆銆mFile.Open("d:\\dd\\try.TRY",CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
銆銆CArchive ar(&mFile,CArchive::store);
銆銆ar<<銆銆ar.Close();
銆銆mFile.Close();
銆銆//瀵規(guī)枃浠惰繘琛岃鎿嶄綔
銆銆CFile mFile;
銆銆if(mFile.Open("d:\\dd\\try.TRY",CFile::modeRead)==0)
銆銆return;
銆銆CArchive ar(&mFile,CArchive::load);
銆 銆ar>>strTemp;
    銆 ar.Close();
銆銆mFile.Close();
銆銆CArchive鐨?<< 鍜?gt;> 鎿嶄綔絎︾敤浜庣畝鍗曟暟鎹被鍨嬬殑璇誨啓錛屽浜嶤Object媧劇敓綾葷殑瀵硅薄鐨勫瓨鍙栬浣跨敤ReadObject()鍜學riteObject()銆備嬌鐢–Archive鐨凴eadClass()鍜學riteClass()榪樺彲浠ヨ繘琛岀被鐨勮鍐欙紝濡傦細
銆銆//瀛樺偍CAboutDlg綾?
銆銆ar.WriteClass(RUNTIME_CLASS(CAboutDlg));
銆銆//璇誨彇CAboutDlg綾?
銆銆CRuntimeClass* mRunClass=ar.ReadClass();
銆銆//浣跨敤CAboutDlg綾?
銆銆CObject* pObject=mRunClass->CreateObject();
    銆銆((CDialog* )pObject)->DoModal();
銆銆铏界劧VC鎻愪緵鐨勬枃妗?瑙嗙粨鏋勪腑鐨勬枃妗d篃鍙繘琛岃繖浜涙搷浣滐紝浣嗘槸涓嶅鏄撶悊瑙c佷嬌鐢ㄥ拰綆$悊錛屽洜姝よ櫧鐒跺緢澶歏C鍏ラ棬鐨勪功涓婅姳璐瑰ぇ閲忕瘒騫呰榪版枃妗?瑙嗙粨鏋勶紝浣嗘垜寤鴻浣犳渶濂戒笉瑕佷嬌鐢ㄥ畠鐨勬枃妗c傚叧浜庡浣曡繘琛屾枃妗?瑙嗙殑鍒嗙鏈夊緢澶氫功浠嬬粛錛屽寘鎷潪甯歌憲鍚嶇殑銆奦isual C++ 鎶鏈唴騫曘嬨?
銆銆濡傛灉浣犺榪涜鐨勬枃浠舵搷浣滃彧鏄畝鍗曠殑璇誨啓鏁磋鐨勫瓧絎︿覆錛屾垜寤鴻浣犱嬌鐢–StdioFile錛岀敤瀹冩潵榪涜姝ょ被鎿嶄綔闈炲父鏂逛究錛屽涓嬩緥銆?
銆銆CStdioFile mFile;
銆銆CFileException mExcept;
銆銆mFile.Open( "d:\\temp\\aa.bat", CFile::modeWrite, &mExcept);
銆銆CString string="I am a string.";
銆銆mFile.WriteString(string);
銆銆mFile.Close();
銆4錛庝復鏃舵枃浠剁殑浣跨敤

銆銆姝h杞歡緇忓父鐢ㄥ埌涓存椂鏂囦歡錛屼綘緇忓父鍙互浼氱湅鍒癈:\Windows\Temp鐩綍涓嬫湁澶ч噺鐨勬墿灞曞悕涓簍mp鐨勬枃浠訛紝榪欎簺灝辨槸紼嬪簭榪愯鏄緩绔嬬殑涓存椂鏂囦歡銆備復鏃舵枃浠剁殑浣跨敤鏂規(guī)硶鍩烘湰涓庡父瑙勬枃浠朵竴鏍鳳紝鍙槸鏂囦歡鍚嶅簲璇ヨ皟鐢ㄥ嚱鏁癎etTempFileName()鑾峰緱銆傚畠鐨勭涓涓弬鏁版槸寤虹珛姝や復鏃舵枃浠剁殑璺緞錛岀浜屼釜鍙傛暟鏄緩绔嬩復鏃舵枃浠跺悕鐨勫墠緙錛岀鍥涗釜鍙傛暟鐢ㄤ簬寰楀埌寤虹珛鐨勪復鏃舵枃浠跺悕銆傚緱鍒版涓存椂鏂囦歡鍚嶄互鍚庯紝浣犲氨鍙互鐢ㄥ畠鏉ュ緩绔嬪茍鎿嶄綔鏂囦歡浜嗭紝濡傦細
銆銆char szTempPath[_MAX_PATH],szTempfile[_MAX_PATH];
銆銆GetTempPath(_MAX_PATH, szTempPath);
銆銆GetTempFileName(szTempPath,_T ("my_"),0,szTempfile);
銆銆CFile m_tempFile(szTempfile,CFile:: modeCreate|CFile:: modeWrite);
銆銆char m_char='a';
銆銆m_tempFile.Write(&m_char,2);
銆銆m_tempFile.Close();
銆銆5錛庢枃浠剁殑澶嶅埗銆佸垹闄ょ瓑
銆銆MFC涓病鏈夋彁渚涚洿鎺ヨ繘琛岃繖浜涙搷浣滅殑鍔熻兘錛屽洜鑰岃浣跨敤SDK銆係DK涓殑鏂囦歡鐩稿叧鍑芥暟甯哥敤鐨勬湁CopyFile()銆丆reateDirectory()銆丏eleteFile()銆丮oveFile()銆傚畠浠殑鐢ㄦ硶寰堢畝鍗曪紝鍙弬鑰僊SDN銆?

1,鍒ゆ柇鏂囦歡鏄惁瀛樺湪
    access(filename,mode);
2,瀵逛簬涓嶅悓鐢ㄩ斿張涓嶅悓鐨勬枃浠舵搷浣?鍏朵腑API鍑芥暟CreateFile()涔熸槸姣旇緝鏈夌敤澶勭悊鏂瑰紡,瀵逛簬宸ㄥ瀷鏂囦歡寰堝悎閫傜殑鍏朵粬鐨勬ゼ涓婄殑澶ч兘璇翠簡,涓嶉噸澶嶄簡.

[1]鏄劇ず瀵硅瘽妗嗭紝鍙栧緱鏂囦歡鍚?/p>

CString FilePathName;
CFileDialog dlg(TRUE);///TRUE涓篛PEN瀵硅瘽妗嗭紝FALSE涓篠***E AS瀵硅瘽妗?br>if (dlg.DoModal() == IDOK)
    FilePathName=dlg.GetPathName();

鐩稿叧淇℃伅錛欳FileDialog 鐢ㄤ簬鍙栨枃浠跺悕鐨勫嚑涓垚鍛樺嚱鏁幫細
鍋囧閫夋嫨鐨勬枃浠舵槸C:\WINDOWS\TEST.EXE
鍒?1)GetPathName();鍙栨枃浠跺悕鍏ㄧО錛屽寘鎷畬鏁磋礬寰勩傚彇鍥濩:\WINDOWS\TEST.EXE
(2)GetFileTitle();鍙栨枃浠跺叏鍚嶏細TEST.EXE
(3)GetFileName();鍙栧洖TEST
(4)GetFileExt();鍙栨墿灞曞悕EXE

[2]鎵撳紑鏂囦歡
CFile file("C:\HELLO.TXT",CFile::modeRead);//鍙鏂瑰紡鎵撳紑
//CFile::modeRead鍙敼涓?CFile::modeWrite(鍙啓),
//CFile::modeReadWrite(璇誨啓),CFile::modeCreate(鏂板緩)
渚嬪瓙錛?br>{
CFile file;
file.Open("C:\HELLO.TXT",CFile::modeCreate|Cfile::modeWrite);
.
.
.
}

[3]縐誨姩鏂囦歡鎸囬拡
file.Seek(100,CFile::begin);///浠庢枃浠跺ご寮濮嬪線涓嬬Щ鍔?00瀛楄妭
file.Seek(-50,CFile::end);///浠庢枃浠舵湯灝懼線涓婄Щ鍔?0瀛楄妭
file.Seek(-30,CFile::current);///浠庡綋鍓嶄綅緗線涓婄Щ鍔?0瀛楄妭
file.SeekToBegin();///縐誨埌鏂囦歡澶?br>file.SeekToEnd();///縐誨埌鏂囦歡灝?/p>

[4]璇誨啓鏂囦歡
璇繪枃浠訛細
char buffer[1000];
file.Read(buffer,1000);
鍐欐枃浠訛細
CString string("鑷己涓嶆伅");
file.Write(string,8);

[5]鍏抽棴鏂囦歡
file.Close();


鏈枃鏉ヨ嚜CSDN鍗氬錛岃漿杞借鏍囨槑鍑哄錛?a >http://blog.csdn.net/zhuang_rui/archive/2007/09/28/1804875.aspx



婕傛紓 2010-03-22 11:09 鍙戣〃璇勮
]]>
浣跨敤OnCtlColor鍑芥暟鏉ユ敼鍙樻帶浠墮鑹?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110180.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sat, 20 Mar 2010 12:29:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110180.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/110180.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110180.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/110180.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/110180.html</trackback:ping><description><![CDATA[<p>鍘熸枃鍦板潃錛歨ttp://lixikeke.blog.hexun.com/25486166_d.html</p><p>鍦∕FC綾誨簱鎻愪緵浜?strong><font color="#0000ff">CWnd</font>::<font color="#993300">OnCtlColor</font></strong>鍑芥暟,鍦ㄥ伐浣滄鏋剁殑瀛愮獥鍙h閲嶇敾鏃跺皢璋冪敤璇ユ垚鍛樺嚱鏁?鍥犳鍙互閲嶈澆<strong>WM_CTLCOLOR</strong>娑堟伅鐨勫搷搴斿嚱鏁?姝ゅ嚱鏁扮殑鍘熷瀷:<br>  <strong>afx_msg HBRUSH OnCtlColor(CDC *pDC,CWnd *pWnd,UINT nCtlColor);<br></strong>           鍙傛暟<strong>nCtlColor</strong>鐢ㄤ簬鎸囧畾鎺т歡鐨勭被鍨?鍙互鏄?<br>           .<strong><font color="#993300">CTLCOLOR_BTN</font></strong>                鎸夐挳鎺т歡<br>           .<strong><font color="#993300">CTLCOLOR_DLG</font></strong>                瀵硅瘽妗?br>           .<font color="#993300"><strong>CTLCOLOR</strong>_<strong>EDIT</strong></font>               緙栬緫妗?br>           .<strong><font color="#993300">CTLCOLOR_LISTBOX</font></strong>            鍒楄〃鎺т歡<br>           .<strong><font color="#993300">CTLCOLOR_MSGBOX</font></strong>             娑堟伅鎺т歡<br>           .<strong><font color="#993300">CTLCOLOR_SCROLLBAR</font></strong> 婊氬姩鏉℃帶浠?br>           .<strong><font color="#993300">CTLCOLOR_STATIC</font></strong>             闈欐佹帶浠?br><strong>[紼嬪簭瀹炵幇]</strong><br>           鍋囪浣犲凡鏈変簡鍚嶄負<strong>My</strong>鐨勫璇濇宸ョ▼.浣犳湁浜嗕竴涓?strong>STATIC</strong>鐨勬帶浠訛紝ID涓?strong><font color="#000000">IDC_STATIC1</font></strong>.<br>  <strong><font color="#0000ff">HBRUSH CMyDlg</font>::<font color="#993300">OnCtlColor</font>(<font color="#0000ff">CDC</font>* pDC, <font color="#0000ff">CWnd</font>* pWnd, <font color="#0000ff">UINT</font> nCtlColor) <br>           {<br>        <font color="#0000ff">HBRUSH</font> hbr = <font color="#0000ff">CDialog</font>::<font color="#993300">OnCtlColor</font>(pDC, pWnd, nCtlColor);<br>  <br>       <font color="#008080"> </font><font color="#339966">// TODO: Change any attributes of the DC here</font><br>           <font color="#0000ff">if </font>(nCtlColor==<font color="#993300">CTLCOLOR_</font><font color="#993300">STATIC</font>)</strong></p> <p><strong>              {<br>                    pDC-><font color="#993300">SetTextColor</font>(<font color="#993300">RGB</font>(255,0,0));</strong>  <font color="#339966">//瀛椾綋棰滆壊<br></font><strong>                    pDC-><font color="#993300">SetBkColor</font>(<font color="#993300">RGB</font>(0, 0, 255));</strong>   <font color="#339966">//瀛椾綋鑳屾櫙鑹?/font><strong>  </strong></p> <p><strong>                }<br>       </strong><strong><font color="#339966"> // TODO: Return a different brush if the default is not desired<br></font>        <font color="#0000ff">return</font> hbr;<br>           }</strong></p> <p><br>濡傛灉瑕佹寚瀹氭煇涓壒瀹氭帶浠跺彲浠ヨ繖鏍峰啓錛?strong><font color="#000000">ID涓篒DC_STATIC1</font></strong></p> <p><font color="#0000ff"><strong>if </strong></font><strong><font color="#000000">(pWnd-><font color="#993300">GetDlgCtrlID</font>()==<font color="#ff00ff">IDC_STATIC1</font>)<br>{<br>       pDC-><font color="#993300">SetTextColor</font></font><font color="#000000">(</font></strong><font color="#000000"><strong><font color="#ff00ff">RGB</font>(255,0,0));  <font color="#339966">//璁劇疆瀛椾綋棰滆壊</font><br>       pDC-><font color="#993300">SetBkMode</font>(<font color="#ff00ff">TRANSPARENT</font>); <font color="#339966">//璁劇疆瀛椾綋鑳屾櫙涓洪忔槑</font><br></strong><font color="#339966"><strong>// TODO: Return a different brush if the default is not desired</strong><br></font><strong>  <font color="#0000ff">return</font> (<font color="#0000ff">HBRUSH</font>)::<font color="#993300">GetStockObject</font>(<font color="#ff00ff">BLACK_BRUSH</font>);  <font color="#339966">// 璁劇疆鑳屾櫙鑹?br></font>}<br><font color="#0000ff">else</font><br><font color="#0000ff">return</font> hbr;</strong></font></p> <p><font color="#000000"><strong>銆愭敞銆?/strong></font></p> <p><font color="#000000"><strong>BLACK_BRUSH:</strong>榛戣壊</font></p> <p><font color="#000000"><strong>WHITE_BRUSH:</strong>鐧借壊</font></p> <p><font color="#000000"><strong>GRAY_BRUSH:</strong>鐏拌壊</font></p> <p><font color="#000000"><strong>NULL_BRUSH:</strong>閫忔槑</font></p> <p><font color="#000000"><font size="2"><strong><font color="#000000">HOLLOW_BRUSH</font></strong> 錛氶忔槑</font></font></p><p><span style="font-size: small;">娉細濡傛灉鍦ㄧ獥浣撲腑浣跨敤榪欑鏂規(guī)硶錛屼細寮曡搗浠g爜鐨勮噧鑲匡紝寤鴻鑷畾涔夎嚜宸辯殑綾匯?/span></p><img src ="http://www.shnenglu.com/AutomateProgram/aggbug/110180.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-20 20:29 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110180.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>VC涔嬬編鍖栫晫闈㈢瘒錛堣漿錛?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110179.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sat, 20 Mar 2010 12:12:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110179.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/110179.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110179.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/110179.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/110179.html</trackback:ping><description><![CDATA[鍘熸枃鍦板潃錛?a >http://blog.csdn.net/bluejoe2000/archive/2009/06/15/4269540.aspx</a> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/110179.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-20 20:12 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110179.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>VS2005涓嬪浣曞畨瑁匴TLhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110153.html婕傛紓婕傛紓Sat, 20 Mar 2010 02:21:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110153.htmlhttp://www.shnenglu.com/AutomateProgram/comments/110153.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/20/110153.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/110153.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/110153.html鍘熸枃鍦板潃錛?a >http://www.cnblogs.com/weitianshui/articles/1017178.html

Windows Template Library - WTL鐨勫畨瑁呮寚鍗楁弧鍦伴兘鏄紝鑰屼笖婧愮▼搴忎篃闄勫甫浜嗗畨瑁呰鏄庯紝浼間箮娌℃湁蹇呰鍐嶅鍐欎竴涓備絾鏄紝浜嬫儏騫舵病鏈夋兂璞$殑閭d箞綆鍗曪紝鏈漢鏈夎繃灝嗚繎4騫寸殑C++寮鍙戠粡楠岋紝鍦ㄤ袱騫村墠鍒氳漿鍏#錛屾湁寰堥暱鏃墮棿娌$C++浜嗭紙鏈鍚庝嬌鐢ㄧ殑宸ュ叿鏄疺C++6.0錛夈備粖澶╃獊鍙戝叴瓚o紝鎯寵鐜╃帺VC++ 2005鍜學TL錛岃皝鐭ワ紝浠ユ垜榪欑緇忛獙錛屾姌鑵捐繖鐪嬫槸綆鍗曠殑鐜╂剰錛屼篃鑺變簡澶у崐澶╃殑鏃墮棿鏂規(guī)墠鎼炲嚭絎竴涓猈TL鐨凥ello World錛屼釜涓洸鎶橈紝璇存潵瀹炲湪鎯劎錛屽彧濂芥妸姝g‘鐨勫畨瑁呰繃紼嬪啓涓涓嬶紝濡傛灉鑳界粰鍒漢涓鐐規(guī)彁紺猴紝閭f槸鏈濂界殑浜嗐傝嚦灝戯紝鍙互鍋氫釜絎旇錛屼袱涓夊勾浠ュ悗濡傛灉鍙堝繕浜嗭紝榪樺彲浠ュ洖鏉ョ炕緲匯?/font>

1銆佷粠http://sourceforge.net/projects/wtl涓嬭澆鏈鏂扮増鏈殑WTL錛屽綋鏃舵槸8.0
2銆佷笅杞藉緱鍒扮殑鏄竴涓嚜瑙e帇鏂囦歡錛屽彲浠ヨВ鍘嬪埌浠繪剰鐩綍銆傛瘮濡俤:\wtl80錛屼笅闈㈡湁鍑犱釜瀛愮洰褰晄amples, include, AppWizMobile, AppWizCE, AppWiz錛岃繕鏈変竴涓猼xt鏂囦歡鍜宧tm鏂囦歡銆傚叾涓璱nclude鏄ご鏂囦歡錛宻amples鏄嚑涓ず渚嬶紝AppWiz*鏄悇縐嶅悜瀵兼枃浠躲?br>3銆佸湪鍛戒護琛岄噷鎵ц錛歸script.exe "D:\WTL80\AppWiz\setup80.js"錛屽鏋滄槸vs2005 express銆乿s2003絳夛紝鍒嗗埆鎵цsetup80x.js, setup70.js,鍙互鐪嬬湅閲岄潰鐨勬枃妗h鏄庛?br>   娉細榪欐槸涓涓緢瀹規(guī)槗璁╀漢鍥版儜鐨勫湴鏂癸紝緗戜笂鐨勬枃妗e叏閮借瑙e帇鍚庢墽琛宻etup80.js鏂囦歡錛屼絾閮芥病璇村浣曟墽琛屻傚悗鏉ュ湪浠g爜閲岀湅鍒版湁WScript錛屾墠鎯沖埌鐢╓SCript.exe鏉ユ墽琛屻?/font>

4銆佹墦寮VS2005, 閫夋嫨VC++欏圭洰錛屽氨鍙互鐪嬪埌WTL欏圭洰鐨勫悜瀵間簡銆?/font>

5銆佸湪VS2005閲岋紝鎵撳紑鑿滃崟“宸ュ叿”鈥斺旈夐」鈥斺旈」鐩拰瑙e喅鏂規(guī)鈥斺擵C++鐩綍錛屽湪“鏄劇ず浠ヤ笅鍐呭鐨勭洰褰?#8221;涓嬫媺妗嗕腑錛岄夋嫨“鍖呭惈鏂囦歡”錛屽姞鍏ュ垰鎵嶈В鍘嬬殑wtl涓嬬殑include錛屾湰渚嬩腑鏄?d:\wtl80\include"銆?/font>

6銆佹寜鐓у悜瀵煎垱寤轟竴涓▼搴忥紝緙栬瘧錛屾墽琛岋紝OK銆?/font>



婕傛紓 2010-03-20 10:21 鍙戣〃璇勮
]]>
TransparentBlt鐨勪嬌鐢?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/110001.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Thu, 18 Mar 2010 07:27:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/110001.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/110001.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/110001.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/110001.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/110001.html</trackback:ping><description><![CDATA[  //鑷畾涔夌粯鍒?br>  CDC* cdc = GetDC();     //鍓嶅彴DC<br>  CDC bufferDC;           //鍚庡彴DC<br>  CDC tempDC;    //涓存椂DC<br>  CBitmap bufferBMP;  //鍚庡彴DC浣嶅浘<br>  //DC鍏寵仈<br>  bufferDC.CreateCompatibleDC(cdc);<br>  tempDC.CreateCompatibleDC(cdc);<br>  //鍚庡彴DC浣嶅浘鍏寵仈        <br>  bufferBMP.CreateCompatibleBitmap(cdc,278,127);        <br>  bufferDC.SelectObject(bufferBMP);<br>  tempDC.SelectObject(m_bmp);<br>  bufferDC.TransparentBlt(0,0,278,127,&tempDC,0,0,278,127,RGB(255,255,255));<br>  //緇樺埗鍒板墠鍙癉C<br>  cdc->BitBlt(0,0,278,127,&bufferDC,0,0,SRCCOPY);<br>  //閲婃斁璧勬簮<br>  bufferBMP.DeleteObject();<br>  tempDC.DeleteDC();<br>  bufferDC.DeleteDC();<br>  this->ReleaseDC(cdc);<br> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/110001.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-18 15:27 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/110001.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>閫忔槑浣嶅浘鐨勬樉紺?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109999.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Thu, 18 Mar 2010 07:18:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109999.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/109999.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109999.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/109999.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/109999.html</trackback:ping><description><![CDATA[     鎽樿: 鍘熸枃鍦板潃錛歨ttp://www.vckbase.com/document/viewdoc/?id=532 鍖呭惈閫忔槑鑹茬殑浣嶅浘鐨勭粯鍒舵柟娉曟湁澶氱錛屾渶綆鍗曠殑鏂規(guī)硶鏄皟鐢ㄧ幇鎴愮殑鍑芥暟錛歍ransparentBlt,涔熷彲浠ラ氳繃鑷繁鐨勪唬鐮佸疄鐜扮被浼糡ransparentBlt鐨勫姛鑳斤紝瀹炵幇榪囩▼涔熸湁涓ょ褰㈠紡錛屼竴縐嶆槸浜嬪厛鍋氫竴寮犳帺鐮佷綅鍥撅紝鍙︿竴縐嶆槸鍔ㄦ佺敓鎴愭帺鐮佷綅鍥俱傛湰鏂囧皢浠嬬粛鍔ㄦ佺敓鎴愭帺鐮佷綅鍥劇粯鍒跺叿鏈夐忔槑鍖哄煙浣嶅浘鐨勬柟娉曘備竴...  <a href='http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109999.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/AutomateProgram/aggbug/109999.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-18 15:18 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109999.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>紼嬪簭鎺у埗妗岄潰鍒囨崲http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109977.html婕傛紓婕傛紓Thu, 18 Mar 2010 05:41:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109977.htmlhttp://www.shnenglu.com/AutomateProgram/comments/109977.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109977.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/109977.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/109977.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/goingup/archive/2006/03/07/618323.aspx

鐢ㄥ悜瀵煎緩绔嬩竴涓猈in32紼嬪簭“hello, world!”錛岀劧鍚庣敤涓嬮潰鐨勫唴瀹規(guī)浛鎹㈡暣涓狢PP鏂囦歡鍐呭灝卞彲浠ヤ簡


#include "stdafx.h"
#include "resource.h"

#include "ShellApi.h"

HINSTANCE hInst = NULL;

HDESK hDesktopCurrent;
HDESK hDesktopLlx;

LONG APIENTRY WndProc(
    HWND hWnd,
    UINT message,      // type of message
    WPARAM wParam,     // additional information
    LPARAM lParam)     // additional information
{
 int wmId, wmEvent;
 PAINTSTRUCT ps;
 HDC hdc;

 switch (message)
 {
  case WM_COMMAND:
   wmId    = LOWORD(wParam);
   wmEvent = HIWORD(wParam);
   // Parse the menu selections:
   switch (wmId)
   {
    case IDM_ABOUT:
       //DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
       break;
    case IDM_EXIT:
       DestroyWindow(hWnd);
       break;
    default:
       return DefWindowProc(hWnd, message, wParam, lParam);
   }
   break;
  case WM_PAINT:
   hdc = BeginPaint(hWnd, &ps);
   // TODO: Add any drawing code here...
   RECT rt;
   GetClientRect(hWnd, &rt);
   //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
   EndPaint(hWnd, &ps);
   break;
  /*
  case WM_DESTROY:
   PostQuitMessage(0);
   break;
  //*/
  case WM_LBUTTONDOWN:
   break;
  case WM_HOTKEY:
   if(7777 == wParam)
   {
    PostQuitMessage(0);
   }
   else if(7778 == wParam)
   {
    SwitchDesktop(hDesktopCurrent);
   }
   else if(7779 == wParam)
   {
    SwitchDesktop(hDesktopLlx);
   }
   break;
  case WM_QUIT:
  case WM_DESTROY:
   SwitchDesktop(hDesktopCurrent);
   return DefWindowProc(hWnd, message, wParam, lParam);
  default:
   return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

void StartMyExplore(void)
{
 STARTUPINFO sui;         // Process startup info
 PROCESS_INFORMATION pi;  // info returned from CreateProcess
 //
 // Most sui members will be 0
 //
 ZeroMemory ((PVOID)&sui, sizeof(sui));

 sui.cb = sizeof (sui);
 //
 // Need the lpDesktop member so the new process runs on this desktop
 // The lpDesktop member was reserved in previous versions of NT
 //
 sui.lpDesktop = _T("llx");
 CreateProcess (NULL,   // image name
      "explorer", // command line
      NULL,   // process security attributes
      NULL,   // thread security attributes
      TRUE,   // inherit handles
      CREATE_DEFAULT_ERROR_MODE|CREATE_SEPARATE_WOW_VDM,
      NULL,   // environment block
      NULL,   // current directory
      &sui,   // STARTUPINFO
      &pi);   // PROCESS_INFORMATION
}

int CALLBACK WinMain( HINSTANCE hInstance,
      HINSTANCE hPrevInstance,
      LPSTR lpCmdLine,
      int nCmdShow)
{
 WNDCLASS wc;
 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc = WndProc;
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.hInstance = hInstance;
 wc.hIcon = LoadIcon (NULL, "IDI_SETTHREADDESKTOP");
 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH);
 wc.lpszMenuName = NULL;
 wc.lpszClassName = "lilinxiang";
 if(!RegisterClass(&wc))
 {
  return TRUE;
 }

 hDesktopCurrent = NULL;
 hDesktopCurrent = GetThreadDesktop(GetCurrentThreadId());

 hDesktopLlx = NULL;
 hDesktopLlx = OpenDesktop("llx", 0, FALSE, NULL);
    if (hDesktopLlx != NULL)
 {
  CloseDesktop(hDesktopLlx);
 }

 SECURITY_ATTRIBUTES sa;
 sa.bInheritHandle = TRUE;
 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
 sa.lpSecurityDescriptor = NULL;

 hDesktopLlx = CreateDesktop("llx", NULL,
                                    NULL,0,MAXIMUM_ALLOWED,
                                    NULL);
 if(hDesktopLlx == NULL)
 {
  return 0;
 }

 if(!SetThreadDesktop(hDesktopLlx))
 {
  char szError[256] = {0};
  ltoa( (long)(GetLastError()) , szError, 10);
 }
 SwitchDesktop(hDesktopLlx);

 HWND hWnd = NULL;
 hWnd = CreateWindow ("lilinxiang",
        "hello, world!",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        0,
        CW_USEDEFAULT,
        0,
        NULL,
        NULL,
        hInstance,
        NULL
        );
 if(NULL == hWnd)
 {
  return TRUE;
 }

 //register hotkey for exit this desktop or switch to another desktop
 //ShowWindow(hWnd, SW_SHOW);
 //UpdateWindow(hWnd);
 if(!RegisterHotKey(hWnd, 7777, MOD_CONTROL, 'Q'))
 {//exit process
  return TRUE;
 }
 if(!RegisterHotKey(hWnd, 7778, MOD_CONTROL | MOD_SHIFT, 'Q'))
 {//switch to new desktop
  return TRUE;
 }
 if(!RegisterHotKey(hWnd, 7779, MOD_CONTROL | MOD_SHIFT, 'W'))
 {//switch to original desktop
  return TRUE;
 }
 
 StartMyExplore();

 MSG msg;
 while (GetMessage(&msg, NULL,  0, 0))
    {
                 TranslateMessage(&msg);// Translates virtual key codes
                 DispatchMessage(&msg); // Dispatches message to window
    }

 SwitchDesktop(hDesktopCurrent);
 return TRUE;
}


//   : )  濂戒笢瑗垮櫌

鐢–reateDesktop鏂板緩涓涓闈紝浠涔堥兘娌℃湁鐨勬闈紝鐒跺悗鍦ㄦ柊妗岄潰鐜涓繍琛屼簡explorer鎵浠ュ氨鏈変簡鍜寃indows涓鏍峰姛鑳界殑妗岄潰錛岃繖涓椂鍊欎綘灝辨湁浜嗕袱涓闈簡錛屼笅闈㈣鍋氱殑灝辨槸鐢⊿witchDesktop鍒囨崲涓嶅悓鐨勬闈簡

鍦ㄤ笉鍚屾闈腑鎵撳紑鐨勭▼搴忓湪鍏朵粬妗岄潰鐨勪換鍔℃爮鍖呮嫭緋葷粺鎵樼洏涓婁笉鍙錛屼笉榪囦換鍔$鐞嗗櫒涓繕鏄彲瑙佺殑榪欐牱浣犲氨闈炲父鏂逛究鐨勫仛寰堝浜嬩簡錛屽緢澶?..  鑰屼笖榪樺彲浠ラ潪甯稿揩鐨勮漿鍒版甯哥姸鎬佷笂鍙互璁╀細璐i獋浣犵殑浜烘瘮濡傝佹澘浠涔堢殑鏃犺瘽鍙錛屽洜涓轟粬浠粈涔堜篃鐪嬩笉鍒?nbsp; : )

鎴栬呬綘涔熷彲浠ョ粰浣犵敤鎴峰畾鍒朵竴涓釜鎬у寲鐨勬闈€傛敼鏀逛笂闈㈢殑浠g爜鍙互寰楀埌浣犺鐨勬晥鏋滅殑銆?/p>


鏈枃鏉ヨ嚜CSDN鍗氬錛岃漿杞借鏍囨槑鍑哄錛?a >http://blog.csdn.net/goingup/archive/2006/03/07/618323.aspx鐢ㄥ悜瀵煎緩绔嬩竴涓猈in32紼嬪簭“hello, world!”錛岀劧鍚庣敤涓嬮潰鐨勫唴瀹規(guī)浛鎹㈡暣涓狢PP鏂囦歡鍐呭灝卞彲浠ヤ簡


#include "stdafx.h"
#include "resource.h"

#include "ShellApi.h"

HINSTANCE hInst = NULL;

HDESK hDesktopCurrent;
HDESK hDesktopLlx;

LONG APIENTRY WndProc(
    HWND hWnd,
    UINT message,      // type of message
    WPARAM wParam,     // additional information
    LPARAM lParam)     // additional information
{
 int wmId, wmEvent;
 PAINTSTRUCT ps;
 HDC hdc;

 switch (message)
 {
  case WM_COMMAND:
   wmId    = LOWORD(wParam);
   wmEvent = HIWORD(wParam);
   // Parse the menu selections:
   switch (wmId)
   {
    case IDM_ABOUT:
       //DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
       break;
    case IDM_EXIT:
       DestroyWindow(hWnd);
       break;
    default:
       return DefWindowProc(hWnd, message, wParam, lParam);
   }
   break;
  case WM_PAINT:
   hdc = BeginPaint(hWnd, &ps);
   // TODO: Add any drawing code here...
   RECT rt;
   GetClientRect(hWnd, &rt);
   //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
   EndPaint(hWnd, &ps);
   break;
  /*
  case WM_DESTROY:
   PostQuitMessage(0);
   break;
  //*/
  case WM_LBUTTONDOWN:
   break;
  case WM_HOTKEY:
   if(7777 == wParam)
   {
    PostQuitMessage(0);
   }
   else if(7778 == wParam)
   {
    SwitchDesktop(hDesktopCurrent);
   }
   else if(7779 == wParam)
   {
    SwitchDesktop(hDesktopLlx);
   }
   break;
  case WM_QUIT:
  case WM_DESTROY:
   SwitchDesktop(hDesktopCurrent);
   return DefWindowProc(hWnd, message, wParam, lParam);
  default:
   return DefWindowProc(hWnd, message, wParam, lParam);
   }
   return 0;
}

void StartMyExplore(void)
{
 STARTUPINFO sui;         // Process startup info
 PROCESS_INFORMATION pi;  // info returned from CreateProcess
 //
 // Most sui members will be 0
 //
 ZeroMemory ((PVOID)&sui, sizeof(sui));

 sui.cb = sizeof (sui);
 //
 // Need the lpDesktop member so the new process runs on this desktop
 // The lpDesktop member was reserved in previous versions of NT
 //
 sui.lpDesktop = _T("llx");
 CreateProcess (NULL,   // image name
      "explorer", // command line
      NULL,   // process security attributes
      NULL,   // thread security attributes
      TRUE,   // inherit handles
      CREATE_DEFAULT_ERROR_MODE|CREATE_SEPARATE_WOW_VDM,
      NULL,   // environment block
      NULL,   // current directory
      &sui,   // STARTUPINFO
      &pi);   // PROCESS_INFORMATION
}

int CALLBACK WinMain( HINSTANCE hInstance,
      HINSTANCE hPrevInstance,
      LPSTR lpCmdLine,
      int nCmdShow)
{
 WNDCLASS wc;
 wc.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
 wc.lpfnWndProc = WndProc;
 wc.cbClsExtra = 0;
 wc.cbWndExtra = 0;
 wc.hInstance = hInstance;
 wc.hIcon = LoadIcon (NULL, "IDI_SETTHREADDESKTOP");
 wc.hCursor = LoadCursor (NULL, IDC_ARROW);
 wc.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH);
 wc.lpszMenuName = NULL;
 wc.lpszClassName = "lilinxiang";
 if(!RegisterClass(&wc))
 {
  return TRUE;
 }

 hDesktopCurrent = NULL;
 hDesktopCurrent = GetThreadDesktop(GetCurrentThreadId());

 hDesktopLlx = NULL;
 hDesktopLlx = OpenDesktop("llx", 0, FALSE, NULL);
    if (hDesktopLlx != NULL)
 {
  CloseDesktop(hDesktopLlx);
 }

 SECURITY_ATTRIBUTES sa;
 sa.bInheritHandle = TRUE;
 sa.nLength = sizeof(SECURITY_ATTRIBUTES);
 sa.lpSecurityDescriptor = NULL;

 hDesktopLlx = CreateDesktop("llx", NULL,
                                    NULL,0,MAXIMUM_ALLOWED,
                                    NULL);
 if(hDesktopLlx == NULL)
 {
  return 0;
 }

 if(!SetThreadDesktop(hDesktopLlx))
 {
  char szError[256] = {0};
  ltoa( (long)(GetLastError()) , szError, 10);
 }
 SwitchDesktop(hDesktopLlx);

 HWND hWnd = NULL;
 hWnd = CreateWindow ("lilinxiang",
        "hello, world!",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT,
        0,
        CW_USEDEFAULT,
        0,
        NULL,
        NULL,
        hInstance,
        NULL
        );
 if(NULL == hWnd)
 {
  return TRUE;
 }

 //register hotkey for exit this desktop or switch to another desktop
 //ShowWindow(hWnd, SW_SHOW);
 //UpdateWindow(hWnd);
 if(!RegisterHotKey(hWnd, 7777, MOD_CONTROL, 'Q'))
 {//exit process
  return TRUE;
 }
 if(!RegisterHotKey(hWnd, 7778, MOD_CONTROL | MOD_SHIFT, 'Q'))
 {//switch to new desktop
  return TRUE;
 }
 if(!RegisterHotKey(hWnd, 7779, MOD_CONTROL | MOD_SHIFT, 'W'))
 {//switch to original desktop
  return TRUE;
 }
 
 StartMyExplore();

 MSG msg;
 while (GetMessage(&msg, NULL,  0, 0))
    {
                 TranslateMessage(&msg);// Translates virtual key codes
                 DispatchMessage(&msg); // Dispatches message to window
    }

 SwitchDesktop(hDesktopCurrent);
 return TRUE;
}


//   : )  濂戒笢瑗垮櫌

鐢–reateDesktop鏂板緩涓涓闈紝浠涔堥兘娌℃湁鐨勬闈紝鐒跺悗鍦ㄦ柊妗岄潰鐜涓繍琛屼簡explorer鎵浠ュ氨鏈変簡鍜寃indows涓鏍峰姛鑳界殑妗岄潰錛岃繖涓椂鍊欎綘灝辨湁浜嗕袱涓闈簡錛屼笅闈㈣鍋氱殑灝辨槸鐢⊿witchDesktop鍒囨崲涓嶅悓鐨勬闈簡

鍦ㄤ笉鍚屾闈腑鎵撳紑鐨勭▼搴忓湪鍏朵粬妗岄潰鐨勪換鍔℃爮鍖呮嫭緋葷粺鎵樼洏涓婁笉鍙錛屼笉榪囦換鍔$鐞嗗櫒涓繕鏄彲瑙佺殑榪欐牱浣犲氨闈炲父鏂逛究鐨勫仛寰堝浜嬩簡錛屽緢澶?..  鑰屼笖榪樺彲浠ラ潪甯稿揩鐨勮漿鍒版甯哥姸鎬佷笂鍙互璁╀細璐i獋浣犵殑浜烘瘮濡傝佹澘浠涔堢殑鏃犺瘽鍙錛屽洜涓轟粬浠粈涔堜篃鐪嬩笉鍒?nbsp; : )

鎴栬呬綘涔熷彲浠ョ粰浣犵敤鎴峰畾鍒朵竴涓釜鎬у寲鐨勬闈€傛敼鏀逛笂闈㈢殑浠g爜鍙互寰楀埌浣犺鐨勬晥鏋滅殑銆?/font>



婕傛紓 2010-03-18 13:41 鍙戣〃璇勮
]]>
RegisterHotKey娉ㄥ唽鐑敭http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109970.html婕傛紓婕傛紓Thu, 18 Mar 2010 03:49:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109970.htmlhttp://www.shnenglu.com/AutomateProgram/comments/109970.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109970.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/109970.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/109970.htmlhotKeyDlg.h
 afx_msg LONG OnHotKey(WPARAM wPARAM, LPARAM lPARAM);

hotKeyDlg.cpp
#define ID_EXIT   0x5000
#define ID_SHOW         0X6000 

BEGIN_MESSAGE_MAP(CHotKeyDlg, CDialog)
 //{{AFX_MSG_MAP(CHotKeyDlg)
 ON_WM_SYSCOMMAND()
 ON_WM_PAINT()
 ON_WM_QUERYDRAGICON()
 ON_MESSAGE(WM_HOTKEY, OnHotKey)

BOOL CHotKeyDlg::OnInitDialog()
{
... 
::RegisterHotKey(m_hWnd, ID_EXIT, MOD_ALT, '5');
 ::RegisterHotKey(m_hWnd, ID_SHOW, MOD_ALT, '6');
}


LONG CHotKeyDlg::OnHotKey(WPARAM wParam,LPARAM lParam)
{
 if (wParam == ID_EXIT)
 {
  PostMessage(WM_QUIT, NULL, NULL);
 }
 if(wParam == ID_SHOW)
 {
  AfxMessageBox("ALT + 6", 0, 0);
 }
 return 0;
}

void CHotKeyDlg::OnDestroy()
{
 CDialog::OnDestroy();
 UnregisterHotKey(m_hWnd, ID_EXIT);
 UnregisterHotKey(m_hWnd, ID_SHOW);
}

婕傛紓 2010-03-18 11:49 鍙戣〃璇勮
]]>
WM_NCLBUTTONDOWN 娑堟伅http://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109963.html婕傛紓婕傛紓Thu, 18 Mar 2010 02:40:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109963.htmlhttp://www.shnenglu.com/AutomateProgram/comments/109963.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/18/109963.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/109963.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/109963.html

The WM_NCLBUTTONDOWN message is posted when the user presses the left mouse button while the cursor is within the nonclient area of a window. This message is posted to the window that contains the cursor. If a window has captured the mouse, this message is not posted.

浣跨敤WM_NCLBUTTONDOWN 娑堟伅錛?br>鍒╃敤鏍囬鏍忕殑娑堟伅錛屾楠梬indows浣垮緱鐐瑰嚮瀹㈡埛鍖哄彲瀹炵幇紿椾綋鐨勭Щ鍔ㄣ傚湪鎵撳嚮瀹㈡埛鍖虹殑鏃跺欏亣浼犳秷鎭粰windows錛屽憡璇変粬鐜板湪宸﹀嚮鏍囬鏍忋?br>
void CDragWindowDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
 // TODO: Add your message handler code here and/or call default
 PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
 CDialog::OnLButtonDown(nFlags, point);
}

C# 浣跨敤WM_NCLBUTTONDOWN娑堟伅瀹炵幇浠繪剰浣嶇疆縐誨姩紿椾綋

public const int WM_NCLBUTTONDOWN = 0xA1;
       public const int HT_CAPTION = 0x2;
    [DllImportAttribute("user32.dll")]
  public static extern int SendMessage(IntPtr hWnd,
                int Msg, int wParam, int lParam);
[DllImportAttribute("user32.dll")]
 public static extern bool ReleaseCapture();

  private void Form1_MouseDown(object sender, MouseEventArgs e)
  {
    if (e.Button == MouseButtons.Left)
{
  if ((e.Clicks == 1))
{
ReleaseCapture();

SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
 }

 }

 }


婕傛紓 2010-03-18 10:40 鍙戣〃璇勮
]]>
COM鑱氬悎 鐢ㄥ埌鐨刢++鐨勪竴浜涗笢瑗?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/16/109840.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Tue, 16 Mar 2010 10:49:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/16/109840.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/109840.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/16/109840.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/109840.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/109840.html</trackback:ping><description><![CDATA[<p>#include <iostream><br>using namespace std;</p> <p>class A<br>{<br>public:<br> virtual void FA() = 0;<br>};<br>class B<br>{<br>public:<br> virtual void FB() = 0;<br>};<br>class C : public A , public B<br>{<br>public:<br> void FA(){cout<<"FA"<<endl;}<br> void FB(){cout<<"FB"<<endl;}<br>};<br>int main()<br>{<br> C* mc = new C();<br> B* mb = static_cast<B*>(mc);<br> ((A*)mb)->FA();<br> return 0;<br>}<br><br>杈撳嚭鐨勬槸FB, com涓埄鐢ㄨ繖鏈哄埗瀹炵幇浜嗚仛鍚堛?/p> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/109840.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-16 18:49 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/16/109840.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>DllMain璇﹁В鍜孌LL 瀹炶返璇存槑 (DllMain鐨勪嬌鐢?http://www.shnenglu.com/AutomateProgram/archive/2010/03/15/109718.html婕傛紓婕傛紓Mon, 15 Mar 2010 01:24:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/03/15/109718.htmlhttp://www.shnenglu.com/AutomateProgram/comments/109718.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/03/15/109718.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/109718.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/109718.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/benkaoya/archive/2008/06/02/2504781.aspx

1  DLL鐨勮繘鍏?閫鍑哄嚱鏁?br>1.1  DllMain綆浠?br>璺焑xe鏈変釜main鎴栬匴inMain鍏ュ彛鍑芥暟涓鏍鳳紝DLL涔熸湁涓涓叆鍙e嚱鏁幫紝灝辨槸DllMain銆備互“DllMain”涓哄叧閿瓧錛屾潵鐪嬬湅MSDN甯姪鏂囨。鎬庝箞浠嬬粛榪欎釜鍑芥暟鐨勩?br>The DllMain function is an optional method of entry into a dynamic-link library (DLL)銆傦紙綆瑕佺炕璇戯細瀵逛簬涓涓狣ll妯″潡錛孌llMain鍑芥暟鏄彲閫夌殑銆傦級榪欏彞璇濆緢閲嶈錛屽緢澶氬垵瀛﹁呭彲鑳介兘璁や負涓涓姩鎬侀摼鎺ュ簱鑲畾瑕佹湁DllMain鍑芥暟銆傚叾瀹炰笉鐒訛紝鍍忓緢澶氫粎浠呭寘鍚祫婧愪俊鎭殑DLL鏄病鏈塂llMain鍑芥暟鐨勩?br>1.2 浣曟椂璋冪敤DllMain
       緋葷粺鏄湪浠涔堟椂鍊欒皟鐢―llMain鍑芥暟鐨勫憿錛熼潤鎬侀摼鎺ユ椂錛屾垨鍔ㄦ侀摼鎺ユ椂璋冪敤LoadLibrary鍜孎reeLibrary閮戒細璋冪敤DllMain鍑芥暟銆侱llMain鐨勭涓変釜鍙傛暟fdwReason鎸囨槑浜嗙郴緇熻皟鐢―ll鐨勫師鍥狅紝瀹冨彲鑳芥槸DLL_PROCESS_ATTACH銆丏LL_PROCESS_DETACH銆丏LL_THREAD_ATTACH鍜孌LL_THREAD_DETACH銆備互涓嬩粠榪欏洓縐嶆儏鍐墊潵鍒嗘瀽緋葷粺浣曟椂璋冪敤浜咲llMain銆?nbsp;           
1.2.1 DLL_PROCESS_ATTACH
       澶у閮界煡閬擄紝涓涓▼搴忚璋冪敤Dll閲岀殑鍑芥暟錛岄鍏堣鍏堟妸DLL鏂囦歡鏄犲皠鍒拌繘紼嬬殑鍦板潃絀洪棿銆傝鎶婁竴涓狣LL鏂囦歡鏄犲皠鍒拌繘紼嬬殑鍦板潃絀洪棿錛屾湁涓ょ鏂規(guī)硶錛氶潤鎬侀摼鎺ュ拰鍔ㄦ侀摼鎺ョ殑LoadLibrary鎴栬匧oadLibraryEx銆?br>       褰撲竴涓狣LL鏂囦歡琚槧灝勫埌榪涚▼鐨勫湴鍧絀洪棿鏃訛紝緋葷粺璋冪敤璇LL鐨凞llMain鍑芥暟錛屼紶閫掔殑fdwReason鍙傛暟涓篋LL_PROCESS_ATTACH銆傝繖縐嶈皟鐢ㄥ彧浼氬彂鐢熷湪絎竴嬈℃槧灝勬椂銆傚鏋滃悓涓涓繘紼嬪悗鏉ヤ負宸茬粡鏄犲皠榪涙潵鐨凞LL鍐嶆璋冪敤LoadLibrary鎴栬匧oadLibraryEx錛屾搷浣滅郴緇熷彧浼氬鍔燚LL鐨勪嬌鐢ㄦ鏁幫紝瀹冧笉浼氬啀鐢―LL_PROCESS_ATTACH璋冪敤DLL鐨凞llMain鍑芥暟銆備笉鍚岃繘紼嬬敤LoadLibrary鍚屼竴涓狣LL鏃訛紝姣忎釜榪涚▼鐨勭涓嬈℃槧灝勯兘浼氱敤DLL_PROCESS_ATTACH璋冪敤DLL鐨凞llMain鍑芥暟銆?br>       鍙弬鑰僁llMainTest鐨凞LL_PROCESS_ATTACH_Test鍑芥暟銆?br>1.2.2 DLL_PROCESS_DETACH
       褰揇LL琚粠榪涚▼鐨勫湴鍧絀洪棿瑙i櫎鏄犲皠鏃訛紝緋葷粺璋冪敤浜嗗畠鐨凞llMain錛屼紶閫掔殑fdwReason鍊兼槸DLL_PROCESS_DETACH銆傚綋DLL澶勭悊璇ュ兼椂錛屽畠搴旇鎵ц榪涚▼鐩稿叧鐨勬竻鐞嗗伐浣溿?br>       閭d箞浠涔堟椂鍊橠LL琚粠榪涚▼鐨勫湴鍧絀洪棿瑙i櫎鏄犲皠鍛紵涓ょ鎯呭喌錛?br>       鈼咶reeLibrary瑙i櫎DLL鏄犲皠錛堟湁鍑犱釜LoadLibrary錛屽氨瑕佹湁鍑犱釜FreeLibrary錛?br>       鈼嗚繘紼嬬粨鏉熻岃В闄LL鏄犲皠錛屽湪榪涚▼緇撴潫鍓嶈繕娌℃湁瑙i櫎DLL鐨勬槧灝勶紝榪涚▼緇撴潫鍚庝細瑙i櫎DLL鏄犲皠銆傦紙濡傛灉榪涚▼鐨勭粓緇撴槸鍥犱負璋冪敤浜員erminateProcess錛岀郴緇熷氨涓嶄細鐢―LL_PROCESS_DETACH鏉ヨ皟鐢―LL鐨凞llMain鍑芥暟銆傝繖灝辨剰鍛崇潃DLL鍦ㄨ繘紼嬬粨鏉熷墠娌℃湁鏈轟細鎵ц浠諱綍娓呯悊宸ヤ綔銆傦級
       娉ㄦ剰錛氬綋鐢―LL_PROCESS_ATTACH璋冪敤DLL鐨凞llMain鍑芥暟鏃訛紝濡傛灉榪斿洖FALSE錛岃鏄庢病鏈夊垵濮嬪寲鎴愬姛錛岀郴緇熶粛浼氱敤DLL_PROCESS_DETACH璋冪敤DLL鐨凞llMain鍑芥暟銆傚洜姝わ紝蹇呴』紜繚娌℃湁娓呯悊閭d簺娌℃湁鎴愬姛鍒濆鍖栫殑涓滆タ銆?br>       鍙弬鑰僁llMainTest鐨凞LL_PROCESS_DETACH_Test鍑芥暟銆?br>1.2.3 DLL_THREAD_ATTACH
       褰撹繘紼嬪垱寤轟竴綰跨▼鏃訛紝緋葷粺鏌ョ湅褰撳墠鏄犲皠鍒拌繘紼嬪湴鍧絀洪棿涓殑鎵鏈塂LL鏂囦歡鏄犲儚錛屽茍鐢ㄥ糄LL_THREAD_ATTACH璋冪敤DLL鐨凞llMain鍑芥暟銆?br>鏂板垱寤虹殑綰跨▼璐熻矗鎵ц榪欐鐨凞LL鐨凞llMain鍑芥暟錛屽彧鏈夊綋鎵鏈夌殑DLL閮藉鐞嗗畬榪欎竴閫氱煡鍚庯紝緋葷粺鎵嶅厑璁歌繘紼嬪紑濮嬫墽琛屽畠鐨勭嚎紼嬪嚱鏁般?br>娉ㄦ剰璺烡LL_PROCESS_ATTACH鐨勫尯鍒紝鎴戜滑鍦ㄥ墠闈㈣榪囷紝絎琻(n>=2)嬈′互鍚庡湴鎶奃LL鏄犲儚鏂囦歡鏄犲皠鍒拌繘紼嬬殑鍦板潃絀洪棿鏃訛紝鏄笉鍐嶇敤DLL_PROCESS_ATTACH璋冪敤DllMain鐨勩傝孌LL_THREAD_ATTACH涓嶅悓錛岃繘紼嬩腑鐨勬瘡嬈″緩绔嬬嚎紼嬶紝閮戒細鐢ㄥ糄LL_THREAD_ATTACH璋冪敤DllMain鍑芥暟錛屽摢鎬曟槸綰跨▼涓緩绔嬬嚎紼嬩篃涓鏍楓?br>1.2.4 DLL_THREAD_DETACH
       濡傛灉綰跨▼璋冪敤浜咵xitThread鏉ョ粨鏉熺嚎紼嬶紙綰跨▼鍑芥暟榪斿洖鏃訛紝緋葷粺涔熶細鑷姩璋冪敤ExitThread錛夛紝緋葷粺鏌ョ湅褰撳墠鏄犲皠鍒拌繘紼嬬┖闂翠腑鐨勬墍鏈塂LL鏂囦歡鏄犲儚錛屽茍鐢―LL_THREAD_DETACH鏉ヨ皟鐢―llMain鍑芥暟錛岄氱煡鎵鏈夌殑DLL鍘繪墽琛岀嚎紼嬬駭鐨勬竻鐞嗗伐浣溿?br>       娉ㄦ剰錛氬鏋滅嚎紼嬬殑緇撴潫鏄洜涓虹郴緇熶腑鐨勪竴涓嚎紼嬭皟鐢ㄤ簡TerminateThread錛岀郴緇熷氨涓嶄細鐢ㄥ糄LL_THREAD_DETACH鏉ヨ皟鐢ㄦ墍鏈塂LL鐨凞llMain鍑芥暟銆?br>1.3  涓篋llMain鎹㈠悕
鍦ㄦ棭鏈熺殑SDK鐗堟湰涓紝DllMain鏄彨鍋欴llEntryPoint銆傚叾瀹炴湁涓浠墮矞涓轟漢鐭ョ殑浜嬶細涓涓狣ll鐨勫叆鍙e嚱鏁板悕鏄彲浠ヨ嚜宸卞畾涔夌殑銆備笅闈㈡垜灝嗕互VC++6.0涓轟緥鏉ユ紨紺哄浣曟洿鏀廣傞鍏堣璇存槑涓鐐癸紝铏界劧DllMain鍙互鎹㈡垚鍏朵粬鍑芥暟鍚嶏紝浣嗗嚱鏁扮殑鍙傛暟鍜岃繑鍥炲煎繀欏誨拰DllMain涓鏍楓傝屼笖榪欎釜鍑芥暟瑕佷負__stdcall綾誨瀷錛圖llMain鏈韓涔熸槸__stdcall綾誨瀷錛夈?br>鎵撳紑VC++鑿滃崟Project\Settings\Link tab\ Output in the Category box錛屽涓嬪浘錛屽湪Entry-point symbol涓緭鍏ヨ鏇挎崲DllMain鐨勫嚱鏁板悕錛堝綋鐒惰繖涓嚱鏁板悕鏄綘紼嬪簭涓凡緇忓疄鐜扮殑鍑芥暟錛夈侲ntry-point symbol鏄共涔堢殑鍛紵鍙互浠ュ叧閿瓧“Entry-point symbol”鎼滅儲MSDN甯姪鏂囨。鏌ョ湅錛屾悳绱㈡椂錛屾墦閽?#8220;浠呮悳绱㈡爣棰?#8221;浼氭洿蹇畾浣嶃?/p>

         鎸塐K鍚庯紝濡傛灉椹笂緙栬瘧鐨勮瘽浼氬嚭鐜板涓嬮敊璇細
LIBCMTD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Dll.dll : fatal error LNK1120: 1 unresolved externals
鎵撳紑VC++鑿滃崟Project\Settings\C/C++閫夐」鍗★紝濡備笅鍥撅紝鍦≒roject Options錛氭湯灝劇殑鍦版柟娣誨姞”/D”錛堝浘涓摑鑹查珮浜殑鍦版柟錛夛紝瑕佹敞鎰忎綅緗紝鎴戣瘯浜嗭紝瑕佹妸/D鏀懼埌/GZ鍚庨潰涔熶細閾炬帴閿欒錛屾垜涔熶笉鎳備負浠涔堬紝^_^銆傛寜OK錛屽啀嬈$紪璇戯紝鎴愬姛銆傚ぇ瀹跺彲浠ヨ嚜宸辨祴璇曚笅鍒板簳鏈夋病鏈夋洿鏀規(guī)垚鍔燂紝浠涔堬紝濡傛灉嫻嬭瘯錛熸墦鍑鴻皟寮忎俊鎭晩銆?/p>

1.4 DisableThreadLibraryCalls
鐪嬪府鍔╁氨鐭ラ亾瀹冩槸騫蹭箞鐢ㄧ殑錛?br>The DisableThreadLibraryCalls function disables the DLL_THREAD_ATTACH and DLL_THREAD_DETACH notifications for the dynamic-link library (DLL) specified by hLibModule. This can reduce the size of the working code set for some applications.

鍘熸枃鍦板潃錛?a >http://www.blogjava.net/Yipak/articles/182025.html

DllMain鐨勪嬌鐢細
DllMain鍑芥暟鏄疍LL妯″潡鐨勯粯璁ゅ叆鍙g偣銆傚綋Windows鍔犺澆DLL妯″潡鏃惰皟鐢ㄨ繖涓鍑芥暟銆傜郴緇熼鍏堣皟鐢ㄥ叏灞瀵硅薄鐨勬瀯閫犲嚱鏁幫紝鐒跺悗璋冪敤鍏ㄥ眬鍑芥暟 DLLMain銆侱LLMain鍑芥暟涓嶄粎鍦ㄥ皢DLL閾炬帴鍔犺澆鍒拌繘紼嬫椂琚皟鐢紝鍦―LL妯″潡涓庤繘紼嬪垎紱繪椂錛堜互鍙婂叾瀹冩椂鍊欙級涔熻璋冪敤銆備笅闈㈡槸涓涓鏋?DLLMain鍑芥暟鐨勪緥瀛愩?br>
濡傛灉鎴戜滑鍦―llMain涓啓鍏ヤ笅闈㈢殑浠g爜錛堝湪鍘熸潵鐨刧andll.c涓坊鍔犱笅闈㈢殑浠g爜錛夛細
BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
    printf("hModule.%p lpReserved.%p \n", hModule, lpReserved);

    switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            printf("Process attach. \n");
            break;

        case DLL_PROCESS_DETACH:
            printf("Process detach. \n");
            break;

        case DLL_THREAD_ATTACH:
            printf("Thread attach. \n");
            break;

        case DLL_THREAD_DETACH:
            printf("Thread detach. \n");
            break;
    }

    return (TRUE);
}

鍚屾椂灝哾lltest\dlltest.c淇敼涓猴細
#include <stdio.h>
#include "dlltest.h"

int main(int argc, char **argv)
{
    printf("Simple DLL test start. \n");

    printf("Call DLL function: \n");
    printf("Test DLL values: %d \n", add2(1, 2));
    printf("Call DLL function end. \n");

    printf("Simple DLL test end. \n");

    return (0);
}

鎴戠畝鍗曠殑嫻嬭瘯涓涓嬭緭鍑虹粨鏋滀負錛?br>C:\gandll\dlltest>dlltest
hModule.10000000 lpReserved.0012FD30
Process attach.
Simple DLL test start.
Call DLL function:
Test DLL values: 3
Call DLL function end.
Simple DLL test end.
hModule.10000000 lpReserved.00000001
Process detach.
涔熷氨鏄DLL鍔犺澆鍜屽簲鐢ㄧ▼搴忛鍑虹殑浣跨敤閮戒細璋冪敤璇ュ嚱鏁幫紙DllMain錛夌殑鍝︼紝 鏄簲鐢ㄧ▼搴忎竴涓婃潵灝辮皟鐢ㄧ殑錛屼笉鏄敤鍒拌鍑芥暟鏃舵墠璋冪敤鐨勶紒

濂借薄鏈変釜闂錛?br>涓嬮潰鐨勮瘽鏉ユ簮錛?a target=_blank>http://waiguai.blogdriver.com/waiguai/989918.html
閲囩敤闅愬紡閾炬帴鏂瑰紡錛岀▼搴忓憳鍦ㄥ緩绔嬩竴涓狣LL鏂囦歡鏃訛紝閾炬帴紼嬪簭浼氳嚜鍔ㄧ敓鎴愪竴涓笌涔嬪搴旂殑LIB瀵煎叆鏂囦歡銆傝鏂囦歡鍖呭惈浜嗘瘡涓涓狣LL瀵煎嚭鍑芥暟鐨勭鍙峰悕鍜屽彲閫夌殑鏍囪瘑鍙鳳紝浣嗘槸騫朵笉鍚湁瀹為檯鐨勪唬鐮併侺IB鏂囦歡浣滀負DLL鐨勬浛浠f枃浠惰緙栬瘧鍒板簲鐢ㄧ▼搴忛」鐩腑銆傚綋紼嬪簭鍛橀氳繃闈欐侀摼鎺ユ柟寮忕紪璇戠敓鎴愬簲鐢ㄧ▼搴忔椂錛屽簲鐢ㄧ▼搴忎腑鐨勮皟鐢ㄥ嚱鏁頒笌LIB鏂囦歡涓鍑虹鍙風浉鍖歸厤錛岃繖浜涚鍙鋒垨鏍囪瘑鍙瘋繘鍏ュ埌鐢熸垚鐨凟XE鏂囦歡涓侺IB鏂囦歡涓篃鍖呭惈浜嗗搴旂殑DLL鏂囦歡鍚嶏紙浣嗕笉鏄畬鍏ㄧ殑璺緞鍚嶏級錛岄摼鎺ョ▼搴忓皢鍏跺瓨鍌ㄥ湪EXE鏂囦歡鍐呴儴銆傚綋搴旂敤紼嬪簭榪愯榪囩▼涓渶瑕佸姞杞紻LL鏂囦歡鏃訛紝Windows鏍規(guī)嵁榪欎簺淇℃伅鍙戠幇騫跺姞杞紻LL錛岀劧鍚庨氳繃絎﹀彿鍚嶆垨鏍囪瘑鍙峰疄鐜板 DLL鍑芥暟鐨勫姩鎬侀摼鎺ャ?br>
鎴戜滑鐪嬩粬璇寸殑“褰撳簲鐢ㄧ▼搴忚繍琛岃繃紼嬩腑闇瑕佸姞杞紻LL鏂囦歡鏃?#8221;錛?鎴戝仛鐨勫疄楠屾祴璇曠殑鏄紝鍦ㄨ緭鍑?br>Simple DLL test start.
Call DLL function:
榪欎袱琛屽簲璇ユ槸涓嶉渶瑕丏LL鐨勫晩錛?鎬庝箞搴旂敤紼嬪簭鍦ㄥ墠闈㈣緭鍑轟簡錛?br>hModule.10000000 lpReserved.0012FD30
Process attach.
榪欎釜鍛紵 榪欏氨璇存槑鍏跺疄搴旂敤紼嬪簭涓涓婃潵灝辮皟鐢ㄤ簡DLL鐨勶紙榪樻湁涓縐嶅彲鑳藉氨鏄粬鏄紜殑錛岀敱浜庣紪璇戝櫒浼樺寲鐨勫師鍥犱嬌鐨勮DLL涓涓婃潵灝辮璋冪敤浜嗭級銆?br>鍒板湴鏄負浠涔堬紵 鍐嶆煡錛屽啀鏌ャ傘傘傘傘傘?


渚嬪瓙錛?br>鍒涘緩涓涓畝鍗曠殑DLL宸ョ▼銆?br>MyDllMain.
淇敼MyDllMain.cpp
#include "stdafx.h"
#include <stdio.h>
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
      )
{
 printf("hModule.%p lpReserved.%p \n", hModule, lpReserved);
  switch (ul_reason_for_call)
    {
        case DLL_PROCESS_ATTACH:
            printf("Process attach. \n");
            break;
        case DLL_PROCESS_DETACH:
            printf("Process detach. \n");
            break;
        case DLL_THREAD_ATTACH:
            printf("Thread attach. \n");
            break;
        case DLL_THREAD_DETACH:
            printf("Thread detach. \n");
            break;
    }
    return TRUE;
}

鍒涘緩涓涓?CPP鏂囦歡
#include "StdAfx.h"
extern "C" int _declspec(dllexport) add(int a, int b)
{
 return a + b;
}

鏂板緩涓涓祴璇曞伐紼嬶細
TestMainDll
TestMainDll.cpp

#include "stdafx.h"
#include <iostream>
#include <windows.h>
using namespace std;
typedef int (*Fun)(int, int);
HINSTANCE hInstance;
Fun fun;
int main(int argc, char* argv[])
{
 hInstance = LoadLibrary("MyDllMain.dll");
    if (!hInstance)
  cout<<"Not Find this Dll"<<endl;
    fun = (Fun)GetProcAddress(hInstance, "add");
    cout<<fun(12,3)<<endl;;
    FreeLibrary(hInstance);
 
 printf("Hello World!\n");
 return 0;
}


婕傛紓 2010-03-15 09:24 鍙戣〃璇勮
]]>
DLL 涓?.def鏂囦歡鐨勪嬌鐢?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/03/13/109614.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sat, 13 Mar 2010 08:45:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/03/13/109614.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/109614.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/03/13/109614.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/109614.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/109614.html</trackback:ping><description><![CDATA[鍘熸枃鍦板潃錛?a href="http://www.shnenglu.com/amyvmiwei/archive/2008/01/02/40203.html">http://www.shnenglu.com/amyvmiwei/archive/2008/01/02/40203.html</a><br><br>DLL涓鍑哄嚱鏁扮殑澹版槑鏈変袱縐嶆柟寮忥細涓縐嶄負鍦ㄥ嚱鏁板0鏄庝腑鍔犱笂__declspec(dllexport)錛岃繖閲屼笉鍐嶄婦渚嬭鏄庯紱鍙﹀涓縐嶆柟寮忔槸閲囩敤妯″潡瀹氫箟(.def) 鏂囦歡澹版槑錛?def鏂囦歡涓洪摼鎺ュ櫒鎻愪緵浜嗘湁鍏寵閾炬帴紼嬪簭鐨勫鍑恒佸睘鎬у強鍏朵粬鏂歸潰鐨勪俊鎭?br><br><br>            棣栧厛鍒涘緩 涓涓狣LL紼嬪簭錛?cpp涓?br>int __stdcall Add(int numa, int numb)<br>{<br>       return (numa + numb);<br>} <p>int __stdcall Sub(int numa, int numb)<br>{<br>        return (numa - numb);<br>}<br><br>鐒跺悗鍒涘緩涓涓?def鐨勬枃浠訛紝鍦ㄩ噷闈㈠姞涓?br></p> <p class=code>;DllTestDef.lib : 瀵煎嚭DLL鍑芥暟<br>;浣滆咃細----<br>LIBRARY defDll.dll<br>EXPORTS <br>Add @ 1<br>Sub @ 2<br><br>           鏈鍚庡垱寤轟竴涓祴璇曠▼搴忥細.cpp鏂囦歡濡備笅錛?br>#include <iostream><br>#include <windows.h><br>using namespace std;</p> <p class=code>typedef int (__stdcall *Fun)(int , int);<br>HINSTANCE hInstance;<br>Fun fun;</p> <p class=code>int main()<br>{<br> hInstance = LoadLibrary("defDll.dll");</p> <p class=code> if (!hInstance)<br>  cout<<"Not Find this Dll"<<endl;<br> fun = (Fun)GetProcAddress(hInstance, MAKEINTRESOURCE(1));<br> cout<<fun(12,3)<<endl;;<br> fun = (Fun)GetProcAddress(hInstance, "Sub");<br> cout<<fun(7, 3)<<endl;<br> FreeLibrary(hInstance);<br>}</p> <p class=code></p> <br><br>璇存槑錛?br>.def鏂囦歡鐨勮鍒欎負錛?br><br>銆銆(1)LIBRARY璇彞璇存槑.def鏂囦歡鐩稿簲鐨凞LL錛?br><br>銆銆(2)EXPORTS璇彞鍚庡垪鍑鴻瀵煎嚭鍑芥暟鐨勫悕縐般傚彲浠ュ湪.def鏂囦歡涓殑瀵煎嚭鍑芥暟鍚嶅悗鍔燖n錛岃〃紺鴻瀵煎嚭鍑芥暟鐨勫簭鍙蜂負n錛堝湪榪涜鍑芥暟璋冪敤鏃訛紝榪欎釜搴忓彿灝嗗彂鎸ュ叾浣滅敤錛夛紱<br><br>銆銆(3).def 鏂囦歡涓殑娉ㄩ噴鐢辨瘡涓敞閲婅寮濮嬪鐨勫垎鍙?(;) 鎸囧畾錛屼笖娉ㄩ噴涓嶈兘涓庤鍙ュ叡浜竴琛屻?br> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/109614.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-03-13 16:45 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/03/13/109614.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>CBitmap, HBITMAP鍜孡oadImagehttp://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106337.html婕傛紓婕傛紓Sun, 24 Jan 2010 07:40:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106337.htmlhttp://www.shnenglu.com/AutomateProgram/comments/106337.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106337.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/106337.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/106337.htmlhttp://blog.csdn.net/newstarao/archive/2009/05/22/4209656.aspx

hbitmap鏄痓itmap鐨勬寚閽堬紝

msdn涓細

Handle to a bitmap.typedef HANDLE HBITMAP;

cbitmap鏄痬fc涓皝瑁卋itmap鐨勭被錛?/p>

msdn涓細

Encapsulates錛堝泭鎷級 a Windows graphics device interface (GDI) bitmap and provides member functions to manipulate錛堟搷浣滐級 the bitmap.

 
class CBitmap : public CGdiObject杞寲鏂規(guī)硶涓ょ錛?br>Attach鍜孎romHandle錛?br>CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
HBITMAP hbm = (HBITMAP)bmp;
CBitmap bmp1;
bmp1.Attach(hbm);
HBITMAP = CBitmap.m_hObject;
CBitmap* = CBitmap.FromHandle(HBITMAP)//宸茬煡
HBITMAP hbit;
CBitmap cb;
cb.FromHandle(hbit);//宸茬煡
CBitmap cb;
HBITMAP hbit=(HBITMAP)cb;
CBitmap bmp;HBITMAP hBmp;
鐩鎬簰杞崲錛歨Bmp=(HBITMAP)bmp.GetSafeHandle();bmp.Attach(hBmp);
娉ㄦ剰鐐癸細Attach鍜孎romHandle鐨勫尯鍒獸romHandle寰楀埌鐨勬寚閽堟槸涓存椂鍙橀噺錛?閫氳繃Attach榪炴帴鐨勫彞鏌勫彲浠ラ暱涔呬繚鐣?浣嗛氳繃FromHandle寰楀埌鐨勫彧鏄殏鏃剁殑,澶ф鍙湪涓涓秷鎭尯闂村唴鏈夋晥,寰堝揩渚夸細琚垹闄?鎵浠ュ熀鏈笂涓嶈兘鐢ㄣ傛垜鐢ㄤ簡FromHandle鐒跺悗涓鐩村嚭閿欙紒錛侊紒

CBitmap 鏃犳硶浠庢枃浠朵腑鍔犺澆浣嶅浘錛屽彲浠ョ敤涓嬮潰鐨勬柟娉曡В鍐熾?/p>  HBITMAP hBitmap;
 //hBitmap = (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), "NetFriend.bmp", IMAGE_BITMAP, 0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);//浠庢枃浠朵腑鍔犺澆錛?br> hBitmap = (HBITMAP)::LoadImage(::AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1), IMAGE_BITMAP, 0,0,LR_CREATEDIBSECTION);//浠庤祫婧愭枃浠朵腑鍔犺澆

婕傛紓 2010-01-24 15:40 鍙戣〃璇勮
]]>
VC涓嬫樉紺轟綅鍥劇殑鍑犵鏂規(guī)硶錛堣漿錛?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106336.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sun, 24 Jan 2010 07:36:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106336.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/106336.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106336.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/106336.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/106336.html</trackback:ping><description><![CDATA[VC涓嬫樉紺轟綅鍥劇殑鍑犵鏂規(guī)硶<br>鎬葷粨涓涓嬪叧浜庝綅鍥劇殑鍑犵鐢ㄦ硶銆?br>璇村埌榪欒繕鏄紑澶寸粰澶у浠嬬粛涓涓嬶紝鏈夊叧浣嶅浘鐨勭煡璇嗗惂錛屼互鍙婂浜庢垜浠瘮杈冩湁鐢ㄧ殑鍑犱釜鍏充簬浣嶅浘鐨勭粨鏋勪綋銆?br>涓.浣嶅浘緇撴瀯濡備笅錛? <div> </div> <div>---- 涓銆丅MP鏂囦歡緇撴瀯 <br>---- 1. BMP鏂囦歡緇勬垚 <br>---- BMP鏂囦歡鐢辨枃浠跺ご銆佷綅鍥句俊鎭ご銆侀鑹蹭俊鎭拰鍥懼艦鏁版嵁鍥涢儴鍒嗙粍鎴愩?nbsp;<br>---- 2. BMP鏂囦歡澶?nbsp;<br>---- BMP鏂囦歡澶存暟鎹粨鏋勫惈鏈塀MP鏂囦歡鐨勭被鍨嬨佹枃浠跺ぇ灝忓拰浣嶅浘璧峰浣嶇疆絳変俊鎭?nbsp;<br>---- 鍏剁粨鏋勫畾涔夊涓?  <br>typedef struct tagBITMAPFILEHEADER<br>{<br>WORDbfType;   // 浣嶅浘鏂囦歡鐨勭被鍨嬶紝蹇呴』涓築M<br>DWORD   bfSize;   // 浣嶅浘鏂囦歡鐨勫ぇ灝忥紝浠ュ瓧鑺備負鍗曚綅<br>WORDbfReserved1;  // 浣嶅浘鏂囦歡淇濈暀瀛楋紝蹇呴』涓?<br>WORDbfReserved2;  // 浣嶅浘鏂囦歡淇濈暀瀛楋紝蹇呴』涓?<br>DWORD   bfOffBits; // 浣嶅浘鏁版嵁鐨勮搗濮嬩綅緗紝浠ョ浉瀵逛簬浣嶅浘<br>// 鏂囦歡澶寸殑鍋忕Щ閲忚〃紺猴紝浠ュ瓧鑺備負鍗曚綅<br>} BITMAPFILEHEADER;<br>---- 3. 浣嶅浘淇℃伅澶?nbsp; <br>BMP浣嶅浘淇℃伅澶存暟鎹敤浜庤鏄庝綅鍥劇殑灝哄絳変俊鎭?br>typedef struct tagBITMAPINFOHEADER{<br>   DWORD  biSize;   // 鏈粨鏋勬墍鍗犵敤瀛楄妭鏁?br>   LONGbiWidth;  // 浣嶅浘鐨勫搴︼紝浠ュ儚绱犱負鍗曚綅<br>   LONGbiHeight; // 浣嶅浘鐨勯珮搴︼紝浠ュ儚绱犱負鍗曚綅<br>   WORD   biPlanes; // 鐩爣璁懼鐨勭駭鍒紝蹇呴』涓?<br>   WORD   biBitCount// 姣忎釜鍍忕礌鎵闇鐨勪綅鏁幫紝蹇呴』鏄?(鍙岃壊),<br>  // 4(16鑹?錛?(256鑹?鎴?4(鐪熷僵鑹?涔嬩竴<br>   DWORD  biCompression;   // 浣嶅浘鍘嬬緝綾誨瀷錛屽繀欏繪槸 0(涓嶅帇緙?,<br>  // 1(BI_RLE8鍘嬬緝綾誨瀷)鎴?(BI_RLE4鍘嬬緝綾誨瀷)涔嬩竴<br>   DWORD  biSizeImage; // 浣嶅浘鐨勫ぇ灝忥紝浠ュ瓧鑺備負鍗曚綅<br>   LONGbiXPelsPerMeter; // 浣嶅浘姘村鉤鍒嗚鯨鐜囷紝姣忕背鍍忕礌鏁?br>   LONGbiYPelsPerMeter;  // 浣嶅浘鍨傜洿鍒嗚鯨鐜囷紝姣忕背鍍忕礌鏁?br>   DWORD  biClrUsed;// 浣嶅浘瀹為檯浣跨敤鐨勯鑹茶〃涓殑棰滆壊鏁?br>   DWORD  biClrImportant;// 浣嶅浘鏄劇ず榪囩▼涓噸瑕佺殑棰滆壊鏁?br>} BITMAPINFOHEADER; <br>---- 4. 棰滆壊琛?nbsp; <br>    棰滆壊琛ㄧ敤浜庤鏄庝綅鍥句腑鐨勯鑹詫紝瀹冩湁鑻ュ共涓〃欏癸紝姣忎竴涓〃欏規(guī)槸涓涓猂GBQUAD綾誨瀷鐨勭粨鏋勶紝瀹氫箟涓縐嶉鑹層俁GBQUAD緇撴瀯鐨勫畾涔夊涓? <br>typedef struct tagRGBQUAD {</div> <div>BYTErgbBlue;// 钃濊壊鐨勪寒搴?鍊艱寖鍥翠負0-255)<br>BYTErgbGreen;   // 緇胯壊鐨勪寒搴?鍊艱寖鍥翠負0-255)<br>BYTErgbRed; // 綰㈣壊鐨勪寒搴?鍊艱寖鍥翠負0-255)<br>BYTErgbReserved;// 淇濈暀錛屽繀欏諱負0<br>} RGBQUAD;<br>棰滆壊琛ㄤ腑RGBQUAD緇撴瀯鏁版嵁鐨勪釜鏁版湁biBitCount鏉ョ‘瀹?<br>褰揵iBitCount=1,4,8鏃訛紝鍒嗗埆鏈?,16,256涓〃欏?<br>褰揵iBitCount=24鏃訛紝娌℃湁棰滆壊琛ㄩ」銆?br>   浣嶅浘淇℃伅澶村拰棰滆壊琛ㄧ粍鎴愪綅鍥句俊鎭紝BITMAPINFO緇撴瀯瀹氫箟濡備笅:<br>typedef struct tagBITMAPINFO {<br>   BITMAPINFOHEADER bmiHeader;   // 浣嶅浘淇℃伅澶?br>   RGBQUAD  bmiColors[1];  // 棰滆壊琛?br>} BITMAPINFO;<br>涓嬮潰鎴戜滑浠嬬粛絎竴縐嶅姙娉曪細<br>//絎竴縐嶆柟娉曪紝浣跨敤WM__CTRLCOLOR鏉ュ疄鐜?br>/*******************OnCtlColor涓坊鍔犵殑浠g爜*****************/<br>HBRUSH CDemoBitmapDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) <br>{<br> HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);<br> <br> // TODO: Change any attributes of the DC here<br> //絎竴縐嶅疄鐜版柟娉?br> if(nCtlColor=CTLCOLOR_DLG)<br> {<br>  return brush;<br> }<br> // TODO: Return a different brush if the default is not desired<br> return hbr;<br>}</div> <div>BOOL CDemoBitmapDlg::OnInitDialog()<br>{<br> //絎竴縐嶆柟娉曪紝浣跨敤wm_ctlcolor鏉ュ疄鐜?br> CBitmap bitmap;<br> bitmap.LoadBitmap(IDB_BITMAP1);<br> brush.CreatePatternBrush(&bitmap);//brush瀹氫箟鍦ㄥご鏂囦歡涓瑿Brush burush<br> bitmap.DeleteObject();<br>}<br>絎簩縐嶆柟娉曚嬌鐢ㄨ祫婧愭枃浠朵腑瀵煎叆鐨処DB_BITMAP鏉ュ疄鐜?br>絎竴姝ュ厛鍦ㄨ祫婧愪腑瀵煎叆涓涓綅鍥?IDB_BITMAP1<br>void CDemoBitmapDlg::OnBtnBitmap() <br>{<br> // TODO: Add your control notification handler code here<br> /***************鏄劇ずBITMAP鐨勭浜岀鏂規(guī)硶**********************/<br> HBITMAP hBitmap;<br> CBitmap bitmap;<br> CClientDC *pDC;<br> pDC=new CClientDC(this);<br> hBitmap=(HBITMAP)::LoadImage(::AfxGetInstanceHandle(),"NetFriend.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br> bitmap.Attach(hBitmap);<br> CDC CDCompatible;<br> CDCompatible.CreateCompatibleDC(pDC);//鍒涘緩鍏煎DC<br> CDCompatible.SelectObject(&bitmap);<br> /*********鍏跺畠鍑犵鏄劇ず鏂瑰紡********/<br>/* pDC->BitBlt(0,0,200,200,&CDCompatible,0,0,SRCCOPY);<br> CDCompatible.SetBkMode(TRANSPARENT);<br> pDC->StretchBlt(0,0,352,288,&CDCompatible,0,0,352,288,SRCCOPY);<br>    CDCompatible.CreateCompatibleDC(this->GetDC());<br>    CDCompatible.SelectObject(&bitmap); */ //閫夋嫨緇樺浘瀵硅薄<br> BITMAP bmp;<br> bitmap.GetBitmap(&bmp);<br>    pDC->StretchBlt(0,0,bmp.bmWidth,bmp.bmHeight,&CDCompatible,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY); <br>    CDCompatible.DeleteDC();  <br>    ::DeleteObject(&bitmap); <br>}<br>絎笁縐嶆柟娉曟槸閫氳繃璇誨彇鎸囧畾鐩綍涓殑浣嶅浘鏂囦歡鏉ユ樉紺?榪欓噷鍒嗗埆鎶婂畠浠樉紺哄湪Picture<a ><font color=#0000ff><u>鎺т歡</u></font></a>鍜孲tatic涓婇潰榪欎篃鏄ぇ瀹墮氬父瑕佺敤鍒扮殑)錛?br>void CDemoBitmapDlg::OnBtnPic() <br>{<br> // TODO: Add your control notification handler code here<br> /****************鍚慞ICTURE<a ><font color=#0000ff><u>鎺т歡</u></font></a>涓姩鎬佹坊鍔犱綅鍥?***************************/<br> HBITMAP hBitmap;<br> CBitmap bitmap;<br> hBitmap=(HBITMAP)::LoadImage(::AfxGetInstanceHandle(),"NetFriend.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br> bitmap.Attach(hBitmap);<br> m_Pic.SetBitmap(hBitmap);</div> <div>}<br>/****************鍦⊿TATIC涓樉紺轟綅鍥?********************/<br>void CDemoBitmapDlg::OnBtnStatic() <br>{<br> // TODO: Add your control notification handler code here<br> CBitmap hbmp;<br> HBITMAP hbitmap;<br> //灝唒Static鎸囧悜瑕佹樉紺虹殑鍦版柟<br> CStatic *pStaic;<br> pStaic=(CStatic*)GetDlgItem(IDC_IMAGE);<br>// pStaic=(CStatic*)GetDlgItem(IDC_BUTTON1);<br> //瑁呰澆璧勬簮 MM.bmp鏄垜鐨勪竴涓枃浠跺悕錛岀敤浣犵殑鏇挎崲<br> hbitmap=(HBITMAP)::LoadImage (::AfxGetInstanceHandle(),"NetFriend.bmp",<br>  IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION); <br> <br> hbmp.Attach(hbitmap);<br> //鑾峰彇鍥劇墖鏍煎紡<br> BITMAP bm;<br> hbmp.GetBitmap(&bm);<br> CDC dcMem;<br> dcMem.CreateCompatibleDC(GetDC());<br> CBitmap *poldBitmap=(CBitmap*)dcMem.SelectObject(hbmp);<br> CRect lRect;<br> pStaic->GetClientRect(&lRect);<br> //鏄劇ず浣嶅浘<br> pStaic->GetDC()->StretchBlt(lRect.left ,lRect.top ,lRect.Width(),lRect.Height(),  &dcMem,0 ,0,bm.bmWidth,bm.bmHeight,SRCCOPY);<br> dcMem.SelectObject(&poldBitmap);<br>}<br>/*****************鍚態(tài)UTTON涓坊鍔營CON*****************************/<br>//鏂規(guī)硶鍜屽鍏ュ叾瀹冧綅鍥劇被浼鹼紝鍦ㄨ繖閲屽氨鍙仛涓涓鏄庝竴涓嬪氨鏄簡銆?nbsp;<br>HICON hIco;<br> hIco=AfxGetApp()->LoadIcon(IDI_ICON1);<br> m_BtnBitmap.SetIcon(hIco);<br>絎洓縐嶈鍙栦綅鍥炬枃浠舵潵鏄劇ず浣嶅浘:<br>void CDemoBitmapDlg::OnBtnBtmfile() <br>{<br> // TODO: Add your control notification handler code here<br> /*******************閫氳繃璇誨彇浣嶅浘鏂囦歡鏉ユ樉紺轟綅鍥?*********************/<br> CString strFileName;<br> strFileName.Format("%s","NetFriend.bmp");<br> //鎴愪綅鍥句俊鎭疊ITMAPINFO<br> BITMAPINFO *bitmapinfo=NULL;<br> BYTE *BmpData=NULL;<br> CFile file;//璇誨彇浣嶅浘淇℃伅<br> //璁劇疆鏂囦歡鐨勬墦寮鏂瑰紡<br> if(!file.Open(strFileName,C<em>file:</em>:modeRead|C<em>file:</em>:typeBinary))<br> {<br>  return;<br> }<br> //BITMAP鏂囦歡澶寸粨鏋勪綋<br> BITMAPFILEHEADER BitmapHead;<br> //璇誨彇浣嶅浘鏂囦歡澶?br> if(file.Read(&BitmapHead,sizeof(BITMAPFILEHEADER))!=sizeof(BITMAPFILEHEADER))<br> {<br>  MessageBox("璇誨彇鏂囦歡澶村け璐?");<br>  return;<br> }<br> if(BitmapHead.bfType!=0x4d42)<br> {<br>  MessageBox("瀵逛笉璧?鎮(zhèn)ㄨ鍙栫殑涓嶆槸浣嶅浘鏂囦歡!");<br>  return;<br> }<br> //浣嶅浘淇℃伅<br> BITMAPINFOHEADER  BitmapInfo;<br> if(file.Read(&BitmapInfo,sizeof(BITMAPINFOHEADER))!=sizeof(BITMAPINFOHEADER))<br> {<br>  MessageBox("璇誨彇浣嶅浘淇℃伅澶辮觸!");<br>  return;<br> }<br> if(BitmapInfo.biBitCount!=24)<br> {<br>  MessageBox("瀵逛笉璧?褰撳墠<a ><font color=#0000ff><u>紼嬪簭</u></font></a>鍙敮鎸?4浣嶄綅鍥句俊鎭?");<br>  return;<br> }<br> bitmapinfo=(BITMAPINFO*)new char[sizeof(BITMAPINFOHEADER)];<br> if(!bitmapinfo)<br> {<br>  MessageBox("鍐呭瓨鍒嗛厤澶辮觸!");<br>  return;<br> }<br> /*鎶夿MP浣嶅浘淇℃伅澶翠腑鐨勬暟鎹鍙栧埌浣嶅浘淇℃伅緇撴瀯涓幓.*/<br> memcpy(bitmapinfo,&BitmapInfo,sizeof(BITMAPINFOHEADER));<br> /*鐢ㄦ潵寰楀埌浣嶅浘鏂囦歡鐨勫ぇ灝?/<br> DWORD dataByte=BitmapHead.bfSize-BitmapHead.bfOffBits;<br> BmpData=(BYTE*)new char[dataByte];<br> if(!BmpData)<br> {<br>  MessageBox("鍐呭瓨鍒嗛厤澶辮觸!");<br>  delete bitmapinfo;<br>  delete BmpData;<br>  return;<br> }<br> if(file.Read(BmpData,dataByte)!=dataByte)<br> {<br>  MessageBox("璇誨彇浣嶅浘鏁版嵁澶辮觸!");<br>  return;<br> }<br> file.Close();<br> CClientDC *pDC=new CClientDC(this);<br> pDC->SetStretchBltMode(COLORONCOLOR);<br> StretchDIBits(pDC->GetSafeHdc(),200,0,BitmapInfo.biWidth,BitmapInfo.biHeight,  0,0,BitmapInfo.biWidth,BitmapInfo.biHeight,BmpData,bitmapinfo,DIB_RGB_COLORS,SRCCOPY);<br>}<br>鏈鍚庣粰澶у浠嬬粛涓や釜鏄劇ず浣嶅浘鐨勭壒鏁堢殑渚嬪瓙鏇村鐨勭壒鏁堟樉紺?/div> <div>1> 姘村鉤浜ら敊鏄劇ず浣嶅浘<br>void CListBmap::OnButton1() <br>{<br> // TODO: Add your control notification handler code here<br> HBITMAP hBitmap;<br> CBitmap cBitmap;<br> hBitmap=(HBITMAP)::LoadImage(::AfxGetInstanceHandle(),"NetFriend.bmp",  IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br> cBitmap.Attach(hBitmap);<br> cBitmap.GetBitmap(&bitmap);<br> int i=0,j=0;<br> CClientDC *pDC=new CClientDC(this);<br> CDC memDC;<br> memDC.CreateCompatibleDC(GetDC());<br> memDC.SelectObject(&cBitmap);<br> for(i=0;i<bitmap.bmHeight;i+=2)<br> {<br>  j=i;<br>  while(j>0)<br>  {<br>   pDC->StretchBlt(0,j-1,bitmap.bmWidth,1,&memDC,0,bitmap.bmHeight-(i-j+1),    bitmap.bmWidth,1,SRCCOPY);<br>   pDC->StretchBlt(0,bitmap.bmHeight-j,bitmap.bmWidth,1,&memDC,0,i-j,    bitmap.bmWidth,1,SRCCOPY);<br>   j-=2;<br>  }<br>  Sleep(50);<br> }</div> <div>}</div> <div>2>闆ㄧ偣鏄劇ず錛?br>void CListBmap::OnButton2() <br>{<br> // TODO: Add your control notification handler code here</div> <div> HBITMAP hBitmap;<br> CBitmap cBitmap;<br> hBitmap=(HBITMAP)::LoadImage(::AfxGetInstanceHandle(),"NetFriend.bmp",  IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);<br> cBitmap.Attach(hBitmap);<br> cBitmap.GetBitmap(&bitmap);<br> int i=0,j=0;<br> CClientDC *pDC=new CClientDC(this);<br> CDC memDC;<br> memDC.CreateCompatibleDC(GetDC());<br> memDC.SelectObject(&cBitmap);<br> for ( i=0; i<=bitmap.bmHeight; i++ )   <br> {<br>  for ( j=0; j<=bitmap.bmHeight-i; j++ )  <br>   pDC->StretchBlt(  <br>   0,j,  <br>   //鐩爣璁懼閫昏緫妯佺旱鍧愭爣  <br>   bitmap.bmWidth,1,  <br>   //鏄劇ず浣嶅浘鐨勫儚绱犲銆侀珮搴?nbsp;<br>   &memDC,  <br>   //婧愪綅鍥捐澶囨儏澧冨璞?nbsp;<br>   0,bitmap.bmHeight-i,  <br>   //婧愪綅鍥劇殑璧峰妯佺旱鍧愭爣  <br>   bitmap.bmWidth,1,  <br>   //婧愪綅鍥劇殑鍍忕礌瀹姐侀珮搴?nbsp; <br>   SRCCOPY);  <br>  Sleep(20);  <br> }<br>}<br></div> <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/106336.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-01-24 15:36 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106336.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>鍔ㄦ佺殑鍒涘緩CStatic騫舵樉紺轟綅鍥俱?/title><link>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106335.html</link><dc:creator>婕傛紓</dc:creator><author>婕傛紓</author><pubDate>Sun, 24 Jan 2010 07:34:00 GMT</pubDate><guid>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106335.html</guid><wfw:comment>http://www.shnenglu.com/AutomateProgram/comments/106335.html</wfw:comment><comments>http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106335.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/AutomateProgram/comments/commentRss/106335.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/AutomateProgram/services/trackbacks/106335.html</trackback:ping><description><![CDATA[ 娉ㄦ剰椋庢牸鐨勮瀹氬惁鍒欐棤娉曟樉紺轟綅鍥俱?br><br>if(m_createPic.m_hWnd == NULL)<br>  m_createPic.Create("", WS_CHILD | <span style="COLOR: red">WS_VISIBLE</span> | WS_TABSTOP | WS_CLIPSIBLINGS | SS_NOTIFY | <span style="COLOR: red">SS_BITMAP</span> , CRect(0,0,150,220),this);<br> CBitmap bmp;<br> bmp.LoadBitmap(IDB_BITMAP1);<br> m_createPic.SetBitmap((HBITMAP)bmp.GetSafeHandle()); <img src ="http://www.shnenglu.com/AutomateProgram/aggbug/106335.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/AutomateProgram/" target="_blank">婕傛紓</a> 2010-01-24 15:34 <a href="http://www.shnenglu.com/AutomateProgram/archive/2010/01/24/106335.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>PreTranslateMessage浣滅敤鍜屼嬌鐢ㄦ柟娉?杞?http://www.shnenglu.com/AutomateProgram/archive/2010/01/18/105917.html婕傛紓婕傛紓Mon, 18 Jan 2010 01:22:00 GMThttp://www.shnenglu.com/AutomateProgram/archive/2010/01/18/105917.htmlhttp://www.shnenglu.com/AutomateProgram/comments/105917.htmlhttp://www.shnenglu.com/AutomateProgram/archive/2010/01/18/105917.html#Feedback0http://www.shnenglu.com/AutomateProgram/comments/commentRss/105917.htmlhttp://www.shnenglu.com/AutomateProgram/services/trackbacks/105917.html鍘熸枃鍦板潃錛?a >http://blog.csdn.net/wzyzb/archive/2009/03/05/3959564.aspx
PreTranslateMessage鏄秷鎭湪閫佺粰TranslateMessage鍑芥暟涔嬪墠琚皟鐢ㄧ殑錛岀粷澶у鏁版湰紿楀彛鐨勬秷鎭兘瑕侀氳繃榪欓噷錛屾瘮杈冨父鐢紝褰撻渶瑕佸湪MFC涔嬪墠澶勭悊鏌愪簺娑堟伅鏃訛紝甯稿父瑕佸湪榪欓噷娣誨姞浠g爜. 
      

       MFC 娑堟伅鎺у埗嫻佹渶鍏風壒鑹茬殑鍦版柟鏄疌Wnd綾葷殑铏氭嫙鍑芥暟PreTranslateMessage()錛岄氳繃閲嶈澆榪欎釜鍑芥暟錛屽彲浠ユ敼鍙楳FC鐨勬秷鎭帶鍒舵祦紼嬶紝鐢氳嚦鍙互浣滀竴涓叏鏂扮殑鎺у埗嫻佸嚭鏉ャ傚彧鏈夌┛榪囨秷鎭槦鍒楃殑娑堟伅鎵嶅彈PreTranslateMessage()褰卞搷錛岄噰鐢⊿endMessage()鎴栧叾浠栫被浼肩殑鏂瑰紡鍚戠獥鍙g洿鎺ュ彂閫佺殑鑰屼笉緇忚繃娑堟伅闃熷垪鐨勬秷鎭牴鏈笉浼氱悊鐫琍reTranslateMessage()鐨勫瓨鍦ㄣ?nbsp;

       鏄惁璋冪敤TranslateMessage()鍜孌ispatchMessage()鏄敱涓涓悕縐頒負PreTranslateMessage()鍑芥暟鐨勮繑鍥炲煎喅瀹氱殑錛屽鏋滆鍑芥暟榪斿洖TRUE錛屽垯涓嶄細鎶婅娑堟伅鍒嗗彂緇欑獥鍙e嚱鏁板鐞嗐?

浼犵粰PreTranslateMessage()鐨勬秷鎭槸鏈粡緲昏瘧榪囩殑娑堟伅錛屽畠娌℃湁緇忚繃TranslateMessage()澶勭悊銆傚彲浠ュ湪璇ュ嚱鏁頒腑浣跨敤(pMsg->wParam==VK_RETURN)鏉ユ嫤鎴洖杞﹂敭銆倃Param涓瓨鏀劇殑鏄敭鐩樹笂瀛楃鐨勮櫄鎷熺爜銆?

PeekMessage鍜孏etMessage鐨勫尯鍒細

GetMessage鍦ㄦ病鏈夋秷鎭殑鏃跺欑瓑寰呮秷鎭紝cpu褰撶劧浣?

PeekMessage娌℃湁娑堟伅鐨勬椂鍊欑珛鍒昏繑鍥烇紝鎵浠pu鍗犵敤鐜囬珮銆?

鍥犱負娓告垙涓嶈兘闈爓indows娑堟伅椹卞姩錛屾墍浠ヨ鐢≒eekMessage();

     PretranslateMessage 鐨勫疄鐜幫紝涓嶅緱涓嶈皥鍒癕FC娑堟伅寰幆鐨勫疄鐜般侻FC閫氳繃CWinApp綾諱腑鐨凱umpmessage鍑芥暟瀹炵幇娑堟伅寰幆錛屼絾鏄疄闄呯殑娑堟伅寰幆浠g爜浣嶄簬 CWinThread涓紝CWinApp鍙槸浠嶤WinThread緇ф壙榪囨潵銆傚叾綆鍖栧悗鐨勪唬鐮佸ぇ姒傚涓嬶細
銆銆BOOL CWinThread::PumpMessage()
銆銆{
銆銆_AFX_THREAD_STATE *pState = AfxGetThreadState();
銆銆
銆銆::GetMessage(&(pState->m_msgCur), NULL, NULL, NULL))
銆銆
銆銆if (!AfxPreTranslateMessage(&(pState->m_msgCur)))
銆銆{
銆銆::TranslateMessage(&(pState->m_msgCur));
銆銆::DispatchMessage(&(pState->m_msgCur));
銆銆}
銆銆return TRUE;
銆銆}
銆銆鍙互鐪嬪埌錛孭umpMessage鍦ㄥ疄闄呯殑TranslateMessage鍜孌ispatchMessage鍙戠敓涔嬪墠浼氳皟鐢?AfxPreTranslateMessage錛孉fxPreTranslateMessage鍙堜細璋冪敤 CWnd::WalkPreTranslateTree(铏界劧涔熶細璋冪敤鍏朵粬鍑芥暟錛屼絾鏄繖涓渶涓哄叧閿級錛屽叾浠g爜濡備笅錛?
銆銆BOOL PASCAL CWnd::WalkPreTranslateTree(HWND hWndStop, MSG* pMsg)
銆銆{
銆銆ASSERT(hWndStop == NULL || ::IsWindow(hWndStop));
銆銆ASSERT(pMsg != NULL);
銆銆
銆銆// walk from the target window up to the hWndStop window checking
銆銆// if any window wants to translate this message
銆銆
銆銆for (HWND hWnd = pMsg->hwnd; hWnd != NULL; hWnd = ::GetParent(hWnd))
銆銆{
銆銆CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);
銆銆if (pWnd != NULL)
銆銆{
銆銆// target window is a C window
銆銆if (pWnd->PreTranslateMessage(pMsg))
銆銆return TRUE; // trapped by target window (eg: accelerators)
銆銆}
銆銆
銆銆// got to hWndStop window without interest
銆銆if (hWnd == hWndStop)
銆銆break;
銆銆}
銆銆return FALSE; // no special processing
銆銆}
銆銆
銆銆鍙互鐪嬪埌錛屼唬鐮佽繕鏄緢鐩存帴鐨勩備粠鎺ュ彈鍒版秷鎭殑紿楀彛灞傚眰寰涓婇亶鍘嗭紝騫惰皟鐢≒retranslateMessage鐪嬫槸鍚﹁繑鍥濼RUE錛屾槸鍒欑粨鏉燂紝鍚﹀垯緇х畫銆?
銆銆榪欓噷鏈変竴涓湴鏂歸潪甯稿叧閿細CWnd *pWnd = CWnd::FromHandlePermanent(hWnd) 榪欎竴鍙ヤ唬鐮佷粠褰撳墠AfxModuleThreadState鎷垮埌Permanent鍙ユ焺琛紝浠庤屾壘鍒癶Wnd瀵瑰簲鐨凜Wnd


MFC 涓璓reTranslateMessage鏄疓etMessage(...)鍑芥暟鐨勪笅涓綰ф搷浣滐紝鍗矴etMessage(...)浠庢秷鎭槦鍒椾腑鑾峰彇娑堟伅鍚庯紝浜ょ敱PreTranslateMessage錛堬級澶勭悊錛岃嫢鍏惰繑鍥濬ALSE鍒欏啀浜ょ粰TranslateMessage鍜?DispatchMessage澶勭悊錛堣繘鍏indowProc錛夛紱  
濡傛灉鐢⊿endMessage,   鍒欐秷鎭洿鎺ヤ氦鍒癢indowProc澶勭悊錛屾墍浠etMessage涓嶄細鍙栧緱SendMessage鐨勬秷鎭紝褰撶劧PreTranslateMessage涔熷氨涓嶄細琚皟鐢ㄣ?nbsp;  [Page]
濡傛灉鐢≒ostMessage,鍒欐秷鎭繘鍏ユ秷鎭槦鍒楋紝鐢盙etMessage鍙栧緱錛孭reTranslateMessage灝辨湁鏈轟細榪涜澶勭悊銆?

渚嬪瓙錛?br>鎸塃nter,ESC鎸夋槸涓嶄細閫鍑轟簡

BOOL CComboBoxExDlg::PreTranslateMessage(MSG* pMsg)
{
if(WM_KEYDOWN == pMsg->message )
{
UINT nKey = (int) pMsg->wParam; 
if( VK_RETURN == nKey || VK_ESCAPE == nKey )
return TRUE ;
}

return CDialog::PreTranslateMessage(pMsg);
}

緙栬緫妗嗭紝濡備綍鍝嶅簲鐨勮繖涓洖杞︾殑淇℃伅
濡傛灉浣犵殑緙栬緫妗嗗畾涔夊涓? 
  CEdidt   m_cName;       //ID鍙蜂負IDC_E_NAME  
   
  BOOL   CSecondDlg::PreTranslateMessage(MSG*   pMsg)    
  {  
  //   TODO:   Add   your   specialized   code   here   and/or   call   class  
   
                if   (pMsg->message==WM_KEYDOWN)  
  {  
          //CWnd   *p=GetDlgItem(IDC_E_NAME);  
  CWnd   *   hWnd=GetFocus();  
  //if(pMsg->wParam==13   &&   pMsg->hwnd==m_cName)  
  if(pMsg->wParam==13   &&   hWnd==&m_cName)  
  {  
  澶勭悊鍑芥暟  
  return   TRUE;  
  }  
  else  
  {  
                                                          澶勭悊鍑芥暟  
  }  
  }  
  return   CDialog::PreTranslateMessage(pMsg);  
  }



婕傛紓 2010-01-18 09:22 鍙戣〃璇勮
]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              欧美日韩三级一区二区| 国产欧美日韩亚洲精品| 亚洲乱码国产乱码精品精天堂| 欧美成人激情视频| 欧美成人三级在线| 中日韩视频在线观看| 亚洲色图综合久久| 国产亚洲观看| 蜜臀久久99精品久久久画质超高清| 久久综合色影院| 99精品视频免费在线观看| 亚洲午夜精品久久久久久浪潮 | 欧美成人精品影院| 欧美精品18+| 午夜精品福利一区二区三区av| 午夜精品短视频| 亚洲国产成人一区| 一区二区三区波多野结衣在线观看| 国产精品久久国产精品99gif| 欧美一区二区三区精品| 美女图片一区二区| 亚洲综合视频在线| 久久香蕉国产线看观看网| 99在线热播精品免费99热| 亚洲欧美日韩电影| 亚洲国产成人高清精品| 亚洲一级黄色| 亚洲人成网站在线观看播放| 亚洲一区三区电影在线观看| 亚洲国产高清一区| 亚洲女同在线| 99精品视频一区二区三区| 欧美自拍偷拍| 亚洲欧美日韩综合国产aⅴ| 久久一综合视频| 午夜亚洲激情| 欧美精品一区二区三区很污很色的| 香蕉成人久久| 欧美日韩免费网站| 亚洲国产精品第一区二区| 国产毛片久久| 在线亚洲一区二区| 亚洲精品一区二区三区99| 久久精品亚洲一区二区三区浴池| 亚洲一区二区高清| 欧美片第1页综合| 蜜桃精品一区二区三区| 国产欧美亚洲精品| 艳妇臀荡乳欲伦亚洲一区| 亚洲精品一区二区在线观看| 久久久久综合网| 久久成人羞羞网站| 国产精品国产三级国产普通话蜜臀| 欧美激情91| 亚洲二区精品| 久久久噜噜噜久久狠狠50岁| 久久九九久精品国产免费直播| 国产精品一区二区a| 在线视频你懂得一区| 亚洲午夜伦理| 欧美午夜精品| 亚洲免费视频中文字幕| 欧美激情乱人伦| 久久精品国产一区二区三| 亚洲女性裸体视频| 亚洲欧美日韩一区在线观看| 欧美亚洲在线| 久久久免费av| 最新高清无码专区| 亚洲图片欧美一区| 欧美一区亚洲| 欧美激情二区三区| 久久综合五月| 亚洲一区二区三区精品在线观看| 亚洲视频电影图片偷拍一区| 亚洲一级在线观看| 国产精品福利在线观看网址| 亚洲影视在线| 久久久福利视频| 亚洲国产精品v| 欧美激情精品久久久久| 亚洲精品欧洲精品| 午夜在线成人av| 狠狠色丁香婷婷综合影院| 久热精品视频在线| 亚洲精品在线免费| 欧美一区二视频| 精品av久久707| 欧美激情1区2区| 亚洲综合日本| 免费观看一区| 亚洲视频综合在线| 国产亚洲一区二区三区| 裸体歌舞表演一区二区| 一区二区欧美日韩| 乱码第一页成人| 一区二区电影免费在线观看| 国产日韩欧美| 欧美久久在线| 久久动漫亚洲| 亚洲看片免费| 久久久www免费人成黑人精品 | 鲁大师影院一区二区三区| 日韩视频永久免费| 久久精品人人做人人综合| 亚洲免费电影在线观看| 国产九九精品| 欧美精品一区二区三区久久久竹菊| 亚洲影视九九影院在线观看| 亚洲福利专区| 欧美在线观看视频在线| 日韩视频一区二区三区在线播放免费观看 | 91久久综合| 久久久亚洲人| 亚洲欧美日韩天堂| 亚洲人成在线免费观看| 国产一区日韩二区欧美三区| 欧美日韩美女在线| 免费成人高清视频| 久久久.com| 欧美亚洲综合在线| 亚洲性夜色噜噜噜7777| 亚洲片在线资源| 欧美成人黄色小视频| 久久久www成人免费毛片麻豆| 中日韩美女免费视频网址在线观看| 在线精品视频免费观看| 国产亚洲亚洲| 国产精品一区二区视频| 欧美视频不卡中文| 欧美精品三区| 欧美精品亚洲二区| 欧美好骚综合网| 欧美成人一区二区三区| 老司机午夜精品视频| 久久久国产91| 久久人91精品久久久久久不卡| 香蕉久久精品日日躁夜夜躁| 亚洲一区二区在线| 亚洲图片欧美午夜| 亚洲一区二区三区四区五区黄| 日韩亚洲欧美高清| 亚洲美女精品成人在线视频| 91久久精品国产91久久性色tv| 亚洲高清资源综合久久精品| 亚洲国产成人高清精品| 亚洲国产成人精品女人久久久 | 好吊日精品视频| 好吊色欧美一区二区三区四区| 国产亚洲福利社区一区| 国产自产v一区二区三区c| 国产一区二区三区在线观看精品 | 国产农村妇女精品一二区| 国产精品美女久久久浪潮软件| 国产精品久久国产精品99gif | 麻豆av一区二区三区久久| 开心色5月久久精品| 欧美成人精品在线播放| 欧美日韩精品一区| 国产精品久久久久aaaa九色| 国产午夜精品久久久久久久| 韩国一区二区三区美女美女秀| 在线精品亚洲一区二区| 亚洲精品色图| 亚洲欧洲av一区二区| 久久九九99| 亚洲高清不卡| 中文在线资源观看网站视频免费不卡 | 欧美va日韩va| 亚洲精品日本| 欧美一级在线视频| 男女视频一区二区| 国产精品成人播放| 激情欧美一区二区三区| 日韩系列在线| 久久精品国产免费| 亚洲国产精品久久| 亚洲一区区二区| 嫩草影视亚洲| 国产精品一香蕉国产线看观看| 黄色欧美成人| 亚洲男人av电影| 欧美成人免费全部| 亚洲图片激情小说| 蜜臀av性久久久久蜜臀aⅴ| 国产精品国产亚洲精品看不卡15| 激情成人在线视频| 亚洲男人天堂2024| 亚洲福利视频一区二区| 午夜精品福利一区二区三区av | 欧美日韩高清在线播放| 国产欧美一区二区精品婷婷| 亚洲青色在线| 久久在线视频在线| 亚洲综合色婷婷| 欧美日韩视频在线一区二区| 亚洲电影免费观看高清| 久久国产88| 亚洲五月婷婷| 欧美视频中文一区二区三区在线观看 |