{"id":1359,"date":"2014-09-27T10:44:07","date_gmt":"2014-09-27T02:44:07","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=1359"},"modified":"2014-09-27T10:47:34","modified_gmt":"2014-09-27T02:47:34","slug":"vc%e8%bf%94%e5%9b%9e%e4%b8%80%e4%b8%aa%e7%bd%91%e7%ab%99%e7%bd%91%e9%a1%b5%e7%9a%84%e7%8a%b6%e6%80%81%e5%93%8d%e5%ba%94%e7%a0%81-%e8%a7%a3%e5%86%b3%e4%ba%86%e8%ae%be%e7%bd%ae%e8%b6%85%e6%97%b6","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/1359","title":{"rendered":"vc++\u8fd4\u56de\u4e00\u4e2a\u7f51\u7ad9\u7f51\u9875\u7684\u72b6\u6001\u54cd\u5e94\u7801-\u89e3\u51b3\u4e86\u8bbe\u7f6e\u8d85\u65f6\u4e0d\u8d77\u4f5c\u7528\u7684\u5fae\u8f6f\u95ee\u9898bug"},"content":{"rendered":"


\n\/\/\u8fd9\u4e2a\u7ebf\u7a0b\u662f\u5355\u72ec\u4e3a\u4e86\u68c0\u6d4bopenurl\u662f\u5426\u8d85\u65f6\u7684\u5b50\u7ebf\u7a0b
\nDWORD WINAPI OpenURLThread(
\nLPVOID lpParameter \/\/thread data
\n)
\n{
\n\/\/bOpenURLOver = false;
\n\/\/pdlg->AddRecord(L\"\u5b50\u7ebf\u7a0b\");
\n\/\/while(!bOpenURLOver)
\n\/\/{
\nCHttpConnection * m_http;
\nCInternetSession CIS;
\n\/\/strURL = L\"http:\/\/www.baidu.com\";
\n\/\/m_http = CIS.OpenURL(strURL);<\/code><\/p>\n

\/\/CHttpFile * pHttpFile = (CHttpFile*) CIS.OpenURL(strURL);
\n\/\/\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4
\nCIS.SetOption(INTERNET_OPTION_CONNECT_TIMEOUT,3000);
\nCHttpFile * pHttpFile = NULL;
\n\/\/CString strURL;
\n\/\/strURL = “http:\/\/www.hnsljd.cn\/news”;<\/p>\n

TRY
\n{
\npHttpFile = (CHttpFile*) CIS.OpenURL(strURL);<\/p>\n

DWORD dwordStatus;
\npHttpFile->QueryInfoStatusCode(dwordStatus);
\nif (dwordStatus == HTTP_STATUS_OK)
\n{
\nCString strStatus;
\nstrStatus.Format(L”%d”,dwordStatus);
\npdlg->m_CtrlList.SetItemText(nRow,3,L”OK(” + strStatus + “)”);
\n}
\nelse
\n{
\nCString strStatus;
\nstrStatus.Format(L”%d”,dwordStatus);
\npdlg->m_CtrlList.SetItemText(nRow,3,L”\u7f51\u5740\u53ef\u80fd\u5df2\u5931\u6548(” + strStatus +”)”);
\n}
\n}
\nCATCH(CInternetException,e)
\n{
\n\/\/AfxMessageBox(L”\u5f02\u5e38”);
\npdlg->m_CtrlList.SetItemText(nRow,3,L”\u5f02\u5e38”);
\n\/\/bOpenURLOver = true;
\n}
\nEND_CATCH
\n\/\/bOpenURLOver = true;
\n\/\/return 0;
\n\/\/}<\/p>\n

\/\/bOpenURLOver = true;
\n\/\/pdlg->AddRecord(L”\u5b50\u7ebf\u7a0bover”);
\nreturn 0;
\n}
\n<\/code><\/p>\n

\u8fd9\u91cc\u662f\u4f60\u7684\u8fc7\u7a0b\u5904\u7406\u51fd\u6570\uff0c\u7528\u6765\u8bbf\u95ee\u4e00\u4e2a\u7f51\u5740\uff0c\u90e8\u5206\u53d8\u91cf\u8bf7\u81ea\u5df1\u8865\u5168\u5427
\n
\n\/\/\u521b\u5efa\u7ebf\u7a0b\u5427
\nHANDLE hThread2;
\nhThread2 = CreateThread(NULL,0,OpenURLThread,NULL,0,NULL);
\n\/\/m_bSubmit = true;
\n\/\/CloseHandle(hThread2);<\/code><\/p>\n

if(WaitForSingleObject(hThread2,5000)==WAIT_TIMEOUT)
\n{
\npdlg->m_CtrlList.SetItemText(nTotalItem,3,L”5\u79d2\u8d85\u65f6\u5f02\u5e38”);<\/p>\n

\/\/ Wait until the worker thread exits
\n\/\/WaitForSingleObject ( hThread2, INFINITE );
\n\/\/cout << “Thread has exited” << endl;
\n\/\/return ;
\n}
\n<\/code>
\n\u5fae\u8f6f\u7684chttpfile\u7684openurl\u8d85\u65f6\u95ee\u9898\uff0c\u5fae\u8f6f\u5b98\u65b9\u5df2\u8bc1\u5b9e\u662f\u4e00\u4e2abug\uff0c\u81ea\u5df1\u5f00\u59cb\u641c\u7d22\u4e86\u4e0b\u89e3\u51b3\u529e\u6cd5\uff0c\u7136\u540e\u5c31\u627e\u4e86\u4e2a\u8fd9\u4e48\u4e2a\u529e\u6cd5\uff0c\u81ea\u5df1\u8bc1\u5b9e\u6b64\u6cd5\u6709\u6548\uff01
\n\u4ee3\u7801\u4e0d\u662f\u5f88\u7cfb\u7edf\uff0c\u8bf7\u60a8\u81ea\u5df1\u67e5\u627e\u8865\u5168\u5427\u3002\u7edd\u5bf9\u53ef\u7528\uff01
\nvc++\u8fd4\u56de\u4e00\u4e2a\u7f51\u7ad9\u7f51\u9875\u7684\u72b6\u6001\u54cd\u5e94\u7801-\u89e3\u51b3\u4e86\u8bbe\u7f6e\u8d85\u65f6\u4e0d\u8d77\u4f5c\u7528\u7684\u5fae\u8f6f\u95ee\u9898bug<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"

\/\/\u8fd9\u4e2a\u7ebf\u7a0b\u662f\u5355\u72ec\u4e3a\u4e86\u68c0\u6d4bopenurl\u662f\u5426\u8d85\u65f6\u7684\u5b50\u7ebf\u7a0b DWORD WINAPI OpenURLThread( LPVOID lpParameter \/\/thread data ) { \/\/bOpenURLOver = false; \/\/pdlg->AddRecord(L”\u5b50\u7ebf\u7a0b”); \/\/while(!bOpenURLOver) \/\/{ CHttpConnection * m_http; CInternetSession CIS; \/\/strURL = L”http:\/\/www.baidu.com”; \/\/m_http = CIS.OpenURL(strURL); \/\/CHttpFi<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,219,9],"tags":[],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1359"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=1359"}],"version-history":[{"count":4,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1359\/revisions"}],"predecessor-version":[{"id":1363,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/1359\/revisions\/1363"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=1359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=1359"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=1359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}