///////////////////////////////////////////////////////////////////////////// //主要功能: // InternetGet类 // //程序编写: 2008-11-09 // // ///////////////////////////////////////////////////////////////////////////// #pragma once #include // MFC socket extensions #include 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);