⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getbreakdowninfo.cpp

📁 类似flashget下载工具代码 本来想在完善了上传的
💻 CPP
字号:
// GetBreakDownInfo.cpp: implementation of the CGetBreakDownInfo class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyInsaneBT.h"
#include "GetBreakDownInfo.h"
//#include "GeoHttpDown.h"
#include <fstream>
#include "MainFrm.h"
#include "DataBase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGetBreakDownInfo* CGetBreakDownInfo::m_BreakDownInfo = NULL;
CGetBreakDownInfo::CGetBreakDownInfo()
{}

CGetBreakDownInfo::~CGetBreakDownInfo()
{}

//获得CFG文件路局
void CGetBreakDownInfo::Get_CFG_Path()
{
     //获得CFG文件path
	 CMainFrame* pFrm = (CMainFrame*)AfxGetApp()->m_pMainWnd;
     CRect rect;
	 pFrm->GetClientRect(&rect);
	 vector<CString>vecPath;
     //查询数据库,获得CFG文件路径
	 //为每一个下载创建一个
	 Get_Cfg_Path_All(vecPath);
	 vector<CString>::iterator it = vecPath.begin();
	 for(;it!=vecPath.end();it++)
	 {
	     CString sPath = *it;
	     CGeoHttpDown* http = new CGeoHttpDown(sPath);
		 http->Create(NULL,NULL,WS_CHILD,rect,pFrm,(UINT)0);
		 //写入列表控件
		 WriteDownLog(pFrm,http);
		 
		 //启动一个下载线程
		 AfxBeginThread(StartDownLoad,(LPVOID)http);
		
		
	 }
	 vecPath.clear();
}

CGetBreakDownInfo* CGetBreakDownInfo::Instace()
{
      if(m_BreakDownInfo==NULL)
		m_BreakDownInfo = new CGetBreakDownInfo;
	  
	  return m_BreakDownInfo;
}


//********************************************************************************** 
//** 函数名称: CGetBreakDownInfo::WriteDownLog
//** 输    入: CWnd* pFrm;CGeoHttpDown* pHttp
//** 输    出: 
//** 功能描述: 启动程序时候将未下载完成的任务添加到list上
//** 作    者: shuyi
//** 创建日期: 2007-7-18
//**************修改记录************************************************************ 
//** 修 改 者: shuyi
//** 修改日期: 2007-7-18
//** 修改描述: 
//** 版    本: V1.0
//********************************************************************************** 
void CGetBreakDownInfo::WriteDownLog(CWnd* pFrm,CGeoHttpDown* pHttp)
{
     
	 CMainFrame* pFrmMain = (CMainFrame*)pFrm;
	 int Index;
	 CMyInsaneBTView* pView = NULL;
	 pView = (CMyInsaneBTView*)pFrmMain->GetActiveView();
	 Index = pView->m_downlisctr.GetItemCount(); //获得行个数
	
	 //文件名字
	 CString FileName= pHttp->m_stHttpDlInfo.m_Filename;
	 pView->m_downlisctr.InsertItem(Index,FileName);
	 //暂停
	 WriteDownLoadLog(Index,1,"暂停");
     //2 进度
	 CString Prsent;
	 float lprsent = pHttp->m_DownInfo->fPercent;
	 Prsent.Format("%.2f",lprsent);
	 WriteDownLoadLog(Index,2,Prsent);
	 //文件大小
     CString filesize;
	 double mk = (float)pHttp->m_DownInfo->lFileLength/(1024*1024);
	 //转换为M单位
	 filesize.Format("%.2f",mk);
	 WriteDownLoadLog(Index,3,filesize);
     //4 下载时间
     CString time = pHttp->m_stHttpDlInfo.time;
     WriteDownLoadLog(Index,4,time);
	 //7 URL
     WriteDownLoadLog(Index,7,pHttp->m_DownInfo->strLocationUrl);

}

//********************************************************************************** 
//** 函数名称: CGetBreakDownInfo::Get_Cfg_Path_All
//** 输    入: 
//** 输    出: 
//** 功能描述: 获得所有CFG文件路径
//** 作    者: shuyi
//** 创建日期: 2007-7-18
//**************修改记录************************************************************ 
//** 修 改 者: shuyi
//** 修改日期: 2007-7-18
//** 修改描述: 
//** 版    本: V1.0
//********************************************************************************** 

void CGetBreakDownInfo::Get_Cfg_Path_All(vector<CString>& vecPath)
{   

    CString strConnect =CDataBase::Instance()->m_Connstring;
	CString sPath;
	CFileFind pFind;
	//连接数据库
	if(!CDataBase::Instance()->Opendb(strConnect))
	{   
		AfxMessageBox("连接数据库失败");
        return;
	}
	//获得代理信息
    CString SQL = "SELECT * FROM CFG_PATH";
    LPProxyInfo proxy = NULL;
    CADORecordset* pRs = new CADORecordset(&(CDataBase::Instance()->m_DBConn));
    if(!pRs->Open((LPCTSTR)SQL))
	    return;
    
	if(!pRs->IsEof())
	{   
		pRs->MoveFirst();
	    while(!pRs->IsEof())
		{   
			
		
		    pRs->GetFieldValue("Path",sPath);
		    //判断文件是否存在
			if(pFind.FindFile(sPath))
			   vecPath.push_back(sPath);
				
				pRs->MoveNext();
            
		
		}//while
	
	}


}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -