亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? webgrab.cpp

?? CWebGrab類使您能夠快速簡潔的從網上下載文件。它支持所有MFC類支持的協議。 這個類使用起來很簡單
?? CPP
字號:
/////////////////////////////////////////////////////////////////////////////
// WebGrab.cpp : implementation file
//
// CWebGrab - CHttpFile wrapper class
//
// Written by Chris Maunder <cmaunder@mail.com>
// Copyright (c) 1998-2002. All Rights Reserved.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is 
// not sold for profit without the authors written consent, and 
// providing that this notice and the authors name and all copyright 
// notices remains intact. 
//
// An email letting me know how you are using it would be nice as well. 
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability for any damage/loss of business that
// this product may cause.
//
// History: 19 Nov 1999 - Release
//          26 Jan 2002 - Update by Bryce to include Proxy support and
//                        property accessors (transfer rate, error msg
//                        etc)
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "WebGrab.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define BUFFER_SIZE 4095

/////////////////////////////////////////////////////////////////////////////
// CWebGrab

CWebGrab::CWebGrab()
{
	m_pSession = NULL;
	m_timeOut = 0;
	m_useProxy = false;
	m_infoStatusCode=0;
}

CWebGrab::~CWebGrab()
{
    Close();
}

BOOL CWebGrab::Initialise(LPCTSTR szAgentName /*=NULL*/, CWnd* pWnd /*=NULL*/)
{
    Close();
	m_infoStatusCode=0;
    m_pSession = new CWebGrabSession(szAgentName, pWnd);

	if (m_timeOut != 0)
		m_pSession->SetOption(INTERNET_OPTION_DATA_RECEIVE_TIMEOUT  ,m_timeOut);

	// added Bryce
	if (m_useProxy)
	{
		char buf[10];
		itoa(m_Port,buf,10);
		CString temp = m_Proxy+":"+(CString)buf;
		INTERNET_PROXY_INFO proxyinfo;
		proxyinfo.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
		proxyinfo.lpszProxy = temp;
		proxyinfo.lpszProxyBypass = NULL;
		m_pSession->SetOption(INTERNET_OPTION_PROXY, (LPVOID)&proxyinfo, sizeof(INTERNET_PROXY_INFO));
	}

	
	return (m_pSession != NULL);
}

void CWebGrab::Close()
{
    if (m_pSession)
    {
        m_pSession->Close();
        delete m_pSession;
    }
    m_pSession = NULL;
}

CString CWebGrab::GetErrorMessage()
{
	return m_pSession->GetErrorMessage();
}

void CWebGrab::SetTimeOut(DWORD timeOut)
{
	m_timeOut = timeOut;
}

double CWebGrab::GetRate()
{
	return m_transferRate;
}

void CWebGrab::SetProxyServer(LPCSTR server)
{
	m_Proxy = server;
}

void CWebGrab::SetProxyPort(UINT port)
{
	m_Port = port;
}

void CWebGrab::SetUseProxy(bool use)
{
	m_useProxy = use;
}

void CWebGrab::SetProxy(LPCSTR proxy, WORD port, bool useProxy )
{
	SetProxyServer(proxy);
	SetProxyPort(port);
	SetUseProxy(useProxy);
}

SHORT CWebGrab::GetErrorCode()
{
	return (!m_ErrorMessage.IsEmpty()); //just for now say...
}

BOOL CWebGrab::GetFile(LPCTSTR szURL, CString& strBuffer, 
                       LPCTSTR szAgentName /*=NULL*/, CWnd* pWnd /*=NULL*/)
{
  //  TRACE1("URL is %s\n", szURL);
	m_rawHeaders ="";
	m_infoStatusCode=0;
	strBuffer.Empty();

    if (!m_pSession && !Initialise(szAgentName, pWnd))
        return FALSE;

    if (pWnd)
        m_pSession->SetStatusWnd(pWnd);

    //m_pSession->SetStatus("Downloading file...");

    DWORD dwCount = 0;
    CHttpFile* pFile = NULL;
    try
    {
        pFile = (CHttpFile*) m_pSession->OpenURL(szURL, 1,
                                                 INTERNET_FLAG_TRANSFER_BINARY 
                                                 //| INTERNET_OPEN_FLAG_USE_EXISTING_CONNECT |
                                                 //| INTERNET_FLAG_DONT_CACHE
                                                 //| INTERNET_FLAG_RELOAD
                                                 );
    
		
	}
    catch (CInternetException* e)
    {
        TCHAR   szCause[255];
        e->GetErrorMessage(szCause, 255);
        m_pSession->SetStatus(szCause);
        // e->ReportError();
        e->Delete();
        delete pFile;
        pFile = NULL;
        return FALSE;
    }
    
    COleDateTime startTime = COleDateTime::GetCurrentTime();
    LPSTR pBuf = NULL;
    if (pFile)
    {
        pBuf = (LPSTR) ::GlobalAlloc(GMEM_FIXED, BUFFER_SIZE+1);
        if (!pBuf)
        {
            pFile->Close();
            delete pFile;
            return FALSE;
        }

        BYTE buffer[BUFFER_SIZE+1];
        try {
            UINT nRead = 0;
            dwCount = 0;
            do
            {
                nRead = pFile->Read(buffer, BUFFER_SIZE);
                if (nRead > 0)
                {
                    buffer[nRead] = 0;

                    LPTSTR ptr = strBuffer.GetBufferSetLength(dwCount + nRead + 1);
                    memcpy(ptr+dwCount, buffer, nRead);

                    dwCount += nRead;
                    strBuffer.ReleaseBuffer(dwCount+1);

                    COleDateTimeSpan elapsed = COleDateTime::GetCurrentTime() - startTime;
                    double dSecs = elapsed.GetTotalSeconds();
                    if (dSecs > 0.0)
					{
                        m_transferRate = (double)dwCount / 1024.0 / dSecs;
						m_pSession->SetStatus("Read %d bytes (%0.1f Kb/s)", 
                                             dwCount, m_transferRate );
						
					}
					else
					{
                        m_pSession->SetStatus("Read %d bytes", dwCount);
						m_transferRate = dwCount;
					}
                }
            }
            while (nRead > 0);
        }
        catch (CFileException *e)
        {
            TCHAR   szCause[255];
            e->GetErrorMessage(szCause, 255);
			m_ErrorMessage = szCause;
            m_pSession->SetStatus(szCause);
            //e->ReportError();
            e->Delete();
            delete pFile;
            ::GlobalFree(pBuf);	// mem leak fix by Niek Albers 
            return FALSE;
        }
        pFile->QueryInfoStatusCode(m_infoStatusCode);       
		pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS ,m_rawHeaders);
        pFile->Close();
	  ::GlobalFree(pBuf);	// mem leak fix by Niek Albers 
        delete pFile;
    }

    m_pSession->SetStatus("");

    return TRUE;
}

DWORD CWebGrab::GetPageStatusCode()
{
	return m_infoStatusCode;
}

CString CWebGrab::GetRawHeaders()
{
	return m_rawHeaders;
}



/////////////////////////////////////////////////////////////////////////////
// CWebGrabSession

CWebGrabSession::CWebGrabSession(LPCTSTR szAgentName) 
                : CInternetSession(szAgentName) // , 1, INTERNET_OPEN_TYPE_PRECONFIG, 
{
    CommonConstruct();
}

CWebGrabSession::CWebGrabSession(LPCTSTR szAgentName, CWnd* pStatusWnd) 
                : CInternetSession(szAgentName) //, 1, INTERNET_OPEN_TYPE_PRECONFIG, 
                //                  NULL, NULL, INTERNET_FLAG_ASYNC)
{
    CommonConstruct();
    m_pStatusWnd = pStatusWnd;
}

CWebGrabSession::~CWebGrabSession()
{
}

void CWebGrabSession::CommonConstruct() 
{
    m_pStatusWnd = NULL;
    try {
        EnableStatusCallback(TRUE);
    }
    catch (...)
    {}
}

// Do not edit the following lines, which are needed by ClassWizard.
#if 0
BEGIN_MESSAGE_MAP(CWebGrabSession, CInternetSession)
	//{{AFX_MSG_MAP(CWebGrabSession)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()
#endif	// 0

/////////////////////////////////////////////////////////////////////////////
// CWebGrabSession member functions

void CWebGrabSession::OnStatusCallback(DWORD dwContext, 
                                       DWORD dwInternetStatus, 
                                       LPVOID lpvStatusInformation, 
                                       DWORD dwStatusInformationLength)
{
	UNUSED_ALWAYS(dwContext);

    // Status callbacks need thread-state protection. 
    AFX_MANAGE_STATE( AfxGetAppModuleState( ) );

    CString str;

	//TRACE1("Internet context=%d: %d\n", dwContext);

	switch (dwInternetStatus)
	{
	case INTERNET_STATUS_RESOLVING_NAME:
		str.Format("Resolving name for %s", lpvStatusInformation);
		break;

	case INTERNET_STATUS_NAME_RESOLVED:
		str.Format("Resolved name for %s", lpvStatusInformation);
		break;

	case INTERNET_STATUS_HANDLE_CREATED:
		//str.Format("Handle %8.8X created", hInternet);
		break;

	case INTERNET_STATUS_CONNECTING_TO_SERVER:
		{
		//sockaddr* pSockAddr = (sockaddr*) lpvStatusInformation;
		str.Format("Connecting to socket address "); //, pSockAddr->sa_data);
		}
		break;

	case INTERNET_STATUS_REQUEST_SENT:
		str.Format("Request sent");
		break;

	case INTERNET_STATUS_SENDING_REQUEST:
		str.Format("Sending request...");
		break;

	case INTERNET_STATUS_CONNECTED_TO_SERVER:
		str.Format("Connected to socket address");
		break;

	case INTERNET_STATUS_RECEIVING_RESPONSE:
        return;
		str.Format("Receiving response...");
		break;

	case INTERNET_STATUS_RESPONSE_RECEIVED:
		str.Format("Response received");
		break;

	case INTERNET_STATUS_CLOSING_CONNECTION:
		str.Format("Closing the connection to the server");
		break;

	case INTERNET_STATUS_CONNECTION_CLOSED:
		str.Format("Connection to the server closed");
		break;

	case INTERNET_STATUS_HANDLE_CLOSING:
        return;
		str.Format("Handle closed");
		break;

	case INTERNET_STATUS_REQUEST_COMPLETE:
        // See the CInternetSession constructor for details on INTERNET_FLAG_ASYNC.
        // The lpvStatusInformation parameter points at an INTERNET_ASYNC_RESULT 
        // structure, and dwStatusInformationLength contains the final completion 
        // status of the asynchronous function. If this is ERROR_INTERNET_EXTENDED_ERROR, 
        // the application can retrieve the server error information by using the 
        // Win32 function InternetGetLastResponseInfo. See the ActiveX SDK for more 
        // information about this function. 
		if (dwStatusInformationLength == sizeof(INTERNET_ASYNC_RESULT))
		{
			INTERNET_ASYNC_RESULT* pResult = (INTERNET_ASYNC_RESULT*) lpvStatusInformation;
			str.Format("Request complete, dwResult = %8.8X, dwError = %8.8X",
				        pResult->dwResult, pResult->dwError);
		}
		else
			str.Format("Request complete");
		break;

	case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
	case INTERNET_STATUS_REDIRECT:
	default:
		str.Format("Unknown status: %d", dwInternetStatus);
		break;
	}

    SetStatus(str);

    TRACE("CWebGrabSession::OnStatusCallback: %s\n",str);
}

void CWebGrabSession::SetStatus(LPCTSTR fmt, ...)
{
    va_list args;
    TCHAR buffer[512];

    va_start(args, fmt);
    _vstprintf(buffer, fmt, args);
    va_end(args);

    TRACE1("CWebGrabSession::SetStatus: %s\n", buffer);
	errorMessage = (CString) buffer;
    if (m_pStatusWnd)
    {
        m_pStatusWnd->SetWindowText(buffer);
        m_pStatusWnd->RedrawWindow();
    }
}

CString CWebGrabSession::GetErrorMessage()
{
	return errorMessage;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品一区二区三区视频在线观看| 777久久久精品| 欧美中文字幕久久| 欧美大黄免费观看| 亚洲精品一二三| 精品亚洲成a人| 精品污污网站免费看| 欧美激情艳妇裸体舞| 午夜精品久久一牛影视| 91视频你懂的| 欧美国产日韩亚洲一区| 老司机午夜精品| 欧美性猛交xxxx乱大交退制版| 中文欧美字幕免费| 激情综合色播五月| 欧美一区二区性放荡片| 一级中文字幕一区二区| 99久久99久久综合| 久久蜜桃av一区精品变态类天堂| 日韩中文字幕91| 欧美午夜电影在线播放| 一区二区在线电影| av综合在线播放| 国产精品久久久久一区二区三区| 另类专区欧美蜜桃臀第一页| 欧美肥妇毛茸茸| 亚洲国产aⅴ天堂久久| 91黄色激情网站| 亚洲精品久久7777| 日本精品一区二区三区高清 | 国产精品久久久久久久蜜臀| 国产一区二区三区免费观看| 精品日韩一区二区| 久久国产精品一区二区| 日韩欧美国产麻豆| 久久精品国产网站| 久久久久久久性| 成人免费观看av| 久久久精品蜜桃| 国产成人av一区二区三区在线观看| 欧美成人伊人久久综合网| 麻豆免费看一区二区三区| 日韩三级电影网址| 久久激情五月婷婷| 久久久久一区二区三区四区| 国产91富婆露脸刺激对白| 国产精品二三区| 一本到不卡精品视频在线观看 | av在线不卡电影| 中文字幕中文字幕一区| 91浏览器入口在线观看| 亚洲综合视频网| 欧美日韩综合不卡| 韩日av一区二区| 国产精品久久久爽爽爽麻豆色哟哟| jlzzjlzz亚洲女人18| 亚洲激情校园春色| 91精品国产综合久久久蜜臀粉嫩| 青青青伊人色综合久久| 日本一区二区三区免费乱视频 | 国产精品成人在线观看| 欧洲av在线精品| 欧美一级片在线看| 日精品一区二区| 久久久久久一级片| 99re在线精品| 日韩专区中文字幕一区二区| 久久久久久久久久看片| 在线看国产一区| 国内精品在线播放| 亚洲天堂成人在线观看| 欧美日韩一区久久| 成人一区二区三区视频在线观看 | 国产成人丝袜美腿| 亚洲一区二区三区四区中文字幕| 日韩三级中文字幕| 99re成人在线| 蜜臀av性久久久久蜜臀av麻豆 | 中文字幕在线观看一区二区| 在线免费不卡电影| 国产美女在线精品| 亚洲一区二区三区不卡国产欧美| 欧美成人aa大片| 欧美性三三影院| 成人综合婷婷国产精品久久蜜臀| 天堂蜜桃91精品| 国产欧美1区2区3区| 777色狠狠一区二区三区| 岛国精品在线观看| 久久精品国产久精国产| 一区二区欧美在线观看| 国产亚洲精久久久久久| 欧美一区二区三区性视频| 91在线视频观看| 国产精品一二三| 免费日韩伦理电影| 亚洲二区在线观看| 亚洲人午夜精品天堂一二香蕉| 91精品在线麻豆| 在线欧美日韩国产| 成人免费观看视频| 国产成人免费高清| 激情伊人五月天久久综合| 午夜精品在线视频一区| 一区二区三区在线播| 国产女人水真多18毛片18精品视频| 欧美一二三四在线| 欧美日韩高清一区二区三区| 在线一区二区观看| 99久久久精品| 99精品在线免费| av电影在线观看完整版一区二区| 国产九色精品成人porny| 老司机免费视频一区二区| 午夜免费久久看| 肉色丝袜一区二区| 奇米影视一区二区三区| 视频在线观看国产精品| 日韩精彩视频在线观看| 日本va欧美va欧美va精品| 日韩不卡一区二区| 老色鬼精品视频在线观看播放| 天堂av在线一区| 免费在线看成人av| 美女视频一区在线观看| 激情另类小说区图片区视频区| 久久精品国产色蜜蜜麻豆| 国产一区视频在线看| 国产精品一卡二卡| 成人爱爱电影网址| 在线免费观看成人短视频| 欧美男女性生活在线直播观看| 欧美三级中文字幕在线观看| 欧美久久久久久蜜桃| 欧美大片日本大片免费观看| 久久亚洲精品国产精品紫薇| 国产精品视频你懂的| 亚洲最新在线观看| 丝袜美腿成人在线| 国产精品原创巨作av| 成人听书哪个软件好| 色老头久久综合| 日韩一区二区三区四区五区六区| 欧美成人猛片aaaaaaa| 国产蜜臀av在线一区二区三区| 综合在线观看色| 亚洲18影院在线观看| 韩国中文字幕2020精品| 成人免费福利片| 欧美乱妇20p| 久久精品网站免费观看| 樱桃视频在线观看一区| 日韩高清不卡一区二区三区| 狠狠色丁香久久婷婷综合_中| 91一区二区在线| 欧美一区永久视频免费观看| 国产女主播在线一区二区| 亚洲一区二区综合| 国产精品一区免费视频| 91蜜桃免费观看视频| 日韩一级免费一区| 亚洲欧美日韩国产手机在线| 免费观看30秒视频久久| 91在线精品一区二区| 日韩一级二级三级精品视频| 国产精品久久综合| 久久精品国产久精国产爱| 99国产精品国产精品久久| 精品精品欲导航| 亚洲日本青草视频在线怡红院 | 韩国成人福利片在线播放| 在线中文字幕一区二区| 久久免费精品国产久精品久久久久| 亚洲已满18点击进入久久| 国产成人精品一区二| 777久久久精品| 伊人性伊人情综合网| 国产sm精品调教视频网站| 欧美日韩不卡在线| 亚洲视频精选在线| 国产69精品久久99不卡| 日韩三级免费观看| 一个色在线综合| 91麻豆.com| 中文字幕一区视频| 国产馆精品极品| 日韩欧美你懂的| 日韩专区欧美专区| 欧美性感一区二区三区| 亚洲男帅同性gay1069| 国产福利一区二区三区视频在线| 欧美一区二区三区电影| 亚洲一区二区三区精品在线| 91原创在线视频| 中文字幕在线一区免费| 国产乱码精品一区二区三区忘忧草 | 久久夜色精品一区| 紧缚奴在线一区二区三区| 欧美一激情一区二区三区| 午夜精品在线看|