You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.7 KiB
C++

/////////////////////////////////////////////////////////////////////////////
//主要功能:
// InternetGet类
//
//程序编写: 2008-11-09
//
//
/////////////////////////////////////////////////////////////////////////////
#pragma once
#include <afxsock.h> // MFC socket extensions
#include <afxinet.h>
class CInternetGet
{
public:
CInternetGet(void);
virtual ~CInternetGet(void);
public:
virtual bool IsOpenConnection(void);
// open the connection
virtual bool OpenConnection(CString server, LPCTSTR lpstrUserName=NULL, LPCTSTR lpstrPassordword=NULL);
// close the connection
virtual bool CloseConnection();
virtual bool Open(LPCTSTR lpstrRemote);
virtual void Close(void);
virtual bool IsOpen(void);
virtual UINT Read(void* lpBuf, UINT nCount);
virtual ULONGLONG Seek(ULONGLONG nOffset, UINT nFrom);
virtual CStdioFile* GetStdioFile(void);
virtual bool GetFile(LPCTSTR lpstrRemote, CFile* fw);
virtual bool GetFile(LPCTSTR lpstrRemote, LPCTSTR lpstrLocal);
virtual void ExchangeBuffer(void* pBuf, UINT len); //读取一段信息后调用,可以用作加解密用
//设置提示信息
virtual void SetInformation(LPCTSTR lpstrInfo);
virtual void SetInformation(UINT nInfoID);
virtual void SetProgressDlg(CWnd* pDlg);
//设置进程条信息
virtual void SetPos(int nPos);
DWORD GetCurrentFileLength(void);
BOOL IsAbortFlag(void);
void SetAbortFlag(BOOL bAbort);
//接收并处理其它消息
void PeekMessageLoop(void);
protected:
CInternetSession *pInternetSession;
BOOL m_bAbortFlag; //是否终止当前的操作
CString strAppName;
DWORD m_uCurFileLength; //下载文件的长度
ULONGLONG m_uTotalRead; //已读文件的总的长度
CString strServerName;
void CatchException(CInternetException* pEx);//获得错误信息
};
CString GetBytesString(ULONGLONG nLength);