📄 afxinet.h
字号:
DWORD m_dwContext;
CInternetSession* m_pSession;
virtual void Close();
CString m_strServerName;
INTERNET_PORT m_nPort;
public:
~CInternetConnection();
DECLARE_DYNAMIC(CInternetConnection)
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
void AssertValid() const;
#endif
};
class CFtpConnection : public CInternetConnection
{
public:
CFtpConnection(CInternetSession* pSession, HINTERNET hConnected,
LPCTSTR pstrServer, DWORD dwContext);
CFtpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
DWORD dwContext = 0,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
BOOL bPassive = FALSE);
BOOL SetCurrentDirectory(LPCTSTR pstrDirName);
BOOL GetCurrentDirectory(CString& strDirName) const;
BOOL GetCurrentDirectory(LPTSTR pstrDirName, LPDWORD lpdwLen) const;
BOOL GetCurrentDirectoryAsURL(LPTSTR pstrName, LPDWORD lpdwLen) const;
BOOL GetCurrentDirectoryAsURL(CString& strDirName) const;
BOOL RemoveDirectory(LPCTSTR pstrDirName);
BOOL CreateDirectory(LPCTSTR pstrDirName);
BOOL Rename(LPCTSTR pstrExisting, LPCTSTR pstrNew);
BOOL Remove(LPCTSTR pstrFileName);
BOOL PutFile(LPCTSTR pstrLocalFile, LPCTSTR pstrRemoteFile,
DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
BOOL GetFile(LPCTSTR pstrRemoteFile, LPCTSTR pstrLocalFile,
BOOL bFailIfExists = TRUE,
DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL,
DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
CInternetFile* OpenFile(LPCTSTR pstrFileName,
DWORD dwAccess = GENERIC_READ,
DWORD dwFlags = FTP_TRANSFER_TYPE_BINARY, DWORD dwContext = 1);
virtual void Close();
// implementation
~CFtpConnection();
protected:
CString m_strServerName;
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void AssertValid() const;
#endif
DECLARE_DYNAMIC(CFtpConnection)
};
class CHttpConnection : public CInternetConnection
{
public:
enum {
_HTTP_VERB_MIN = 0,
HTTP_VERB_POST = 0,
HTTP_VERB_GET = 1,
HTTP_VERB_HEAD = 2,
HTTP_VERB_PUT = 3,
HTTP_VERB_LINK = 4,
HTTP_VERB_DELETE = 5,
HTTP_VERB_UNLINK = 6,
_HTTP_VERB_MAX = 6,
};
public:
CHttpConnection(CInternetSession* pSession, HINTERNET hConnected,
LPCTSTR pstrServer, DWORD dwContext);
CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
DWORD dwContext = 1);
CHttpConnection(CInternetSession* pSession, LPCTSTR pstrServer,
DWORD dwFlags, INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER,
LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
DWORD dwContext = 1);
CHttpFile* OpenRequest(LPCTSTR pstrVerb, LPCTSTR pstrObjectName,
LPCTSTR pstrReferer = NULL,DWORD dwContext = 1,
LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT);
CHttpFile* OpenRequest(int nVerb, LPCTSTR pstrObjectName,
LPCTSTR pstrReferer = NULL, DWORD dwContext = 1,
LPCTSTR* ppstrAcceptTypes = NULL, LPCTSTR pstrVersion = NULL,
DWORD dwFlags = INTERNET_FLAG_EXISTING_CONNECT);
// implementation
~CHttpConnection();
virtual void Close();
protected:
CString m_strServerName;
static const LPCTSTR szHtmlVerbs[];
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void AssertValid() const;
#endif
friend class CInternetSession; // just to access szHtmlVerbs
DECLARE_DYNAMIC(CHttpConnection)
};
class CGopherConnection : public CInternetConnection
{
public:
CGopherConnection(CInternetSession* pSession,
HINTERNET hConnected, LPCTSTR pstrServer, DWORD dwContext);
CGopherConnection(CInternetSession* pSession, LPCTSTR pstrServer,
LPCTSTR pstrUserName = NULL, LPCTSTR pstrPassword = NULL,
DWORD dwContext = 0,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
CGopherFile* OpenFile(CGopherLocator& refLocator, DWORD dwFlags = 0,
LPCTSTR pstrView = NULL, DWORD dwContext = 1);
CGopherLocator CreateLocator(LPCTSTR pstrDisplayString,
LPCTSTR pstrSelectorString, DWORD dwGopherType);
BOOL CGopherConnection::GetAttribute(CGopherLocator& refLocator,
CString strRequestedAttributes, CString& strResult);
static CGopherLocator CreateLocator(LPCTSTR pstrLocator);
static CGopherLocator CreateLocator(LPCTSTR pstrServerName,
LPCTSTR pstrDisplayString,
LPCTSTR pstrSelectorString, DWORD dwGopherType,
INTERNET_PORT nPort = INTERNET_INVALID_PORT_NUMBER);
// implementation
~CGopherConnection();
virtual void Close();
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void AssertValid() const;
#endif
DECLARE_DYNAMIC(CGopherConnection)
};
/////////////////////////////////////////////////////////////////////////////
// CFtpFileFind
class CFtpFileFind : public CFileFind
{
public:
CFtpFileFind(CFtpConnection* pConnection, DWORD dwContext = 1);
virtual ~CFtpFileFind();
virtual BOOL FindFile(LPCTSTR pstrName = NULL,
DWORD dwFlags = INTERNET_FLAG_RELOAD);
virtual BOOL FindNextFile();
CString GetFileURL() const;
// implementation
protected:
virtual void CloseContext();
CFtpConnection* m_pConnection;
DWORD m_dwContext;
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void AssertValid() const;
#endif
DECLARE_DYNAMIC(CFtpFileFind)
};
/////////////////////////////////////////////////////////////////////////////
// CGopherLocator
class CGopherLocator : public CObject
{
public:
~CGopherLocator();
operator LPCTSTR() const;
CGopherLocator(const CGopherLocator& ref);
BOOL GetLocatorType(DWORD& dwRef) const;
private:
// this only created by CGopherConnection::CreateLocator or by serialization
CGopherLocator(LPCTSTR pstrLocator, DWORD dwLocLen);
CString m_Locator; // _not_ a zero-terminated string!
DWORD m_dwBufferLength;
friend class CGopherConnection;
friend class CGopherFile;
};
/////////////////////////////////////////////////////////////////////////////
// CGopherFile
class CGopherFile : public CInternetFile
{
// Constructors
protected:
CGopherFile(HINTERNET hFile, CGopherLocator& refLocator,
CGopherConnection* pConnection);
CGopherFile(HINTERNET hFile, HINTERNET hSession,
LPCTSTR pstrLocator, DWORD dwLocLen, DWORD dwContext);
// Operations
public:
virtual void Close();
virtual void Write(const void* lpBuf, UINT nCount);
void WriteString(LPCTSTR pstr);
// Implementation
protected:
CGopherLocator m_Locator;
public:
virtual ~CGopherFile();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
friend class CInternetSession;
friend class CGopherConnection;
DECLARE_DYNAMIC(CGopherFile)
};
/////////////////////////////////////////////////////////////////////////////
// CGopherFileFind
class CGopherFileFind : public CFileFind
{
public:
CGopherFileFind(CGopherConnection* pConnection, DWORD dwContext = 1);
virtual ~CGopherFileFind();
virtual BOOL FindFile(CGopherLocator& refLocator, LPCTSTR pstrString,
DWORD dwFlags = INTERNET_FLAG_RELOAD);
virtual BOOL FindFile(LPCTSTR pstrString,
DWORD dwFlags = INTERNET_FLAG_RELOAD);
virtual BOOL FindNextFile();
virtual BOOL IsDots() const;
virtual BOOL GetLastWriteTime(FILETIME* pTimeStamp) const;
virtual BOOL GetLastAccessTime(FILETIME* pTimeStamp) const;
virtual BOOL GetCreationTime(FILETIME* pTimeStamp) const;
virtual BOOL GetLastWriteTime(CTime& refTime) const;
virtual BOOL GetLastAccessTime(CTime& refTime) const;
virtual BOOL GetCreationTime(CTime& refTime) const;
CGopherLocator GetLocator() const;
CString GetScreenName() const;
virtual DWORD GetLength() const;
#if defined(_X86_) || defined(_ALPHA_)
virtual __int64 GetLength64() const;
#endif
protected:
virtual void CloseContext();
CGopherConnection* m_pConnection;
DWORD m_dwContext;
// implementation
public:
// Unsupported APIs
CString GetFileName() const;
CString GetFilePath() const;
CString GetFileTitle() const;
CString GetFileURL() const;
CString GetRoot() const;
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
virtual void AssertValid() const;
#endif
DECLARE_DYNAMIC(CGopherFileFind)
};
///////////////////////////////////////////////////////////////////////
// CInternetException
class CInternetException : public CException
{
public:
// Constructor
CInternetException(DWORD dwError);
// Attributes
DWORD m_dwError;
DWORD m_dwContext;
// Implementation
public:
~CInternetException();
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
virtual BOOL GetErrorMessage(LPTSTR lpstrError, UINT nMaxError,
PUINT pnHelpContext = NULL);
DECLARE_DYNAMIC(CInternetException)
};
/////////////////////////////////////////////////////////////////////////////
// Inline function declarations
#ifdef _AFX_ENABLE_INLINES
#define _AFXINET_INLINE AFX_INLINE
#include <afxinet.inl>
#endif
#undef AFX_DATA
#define AFX_DATA
#ifdef _AFX_MINREBUILD
#pragma component(minrebuild, on)
#endif
#ifndef _AFX_FULLTYPEINFO
#pragma component(mintypeinfo, off)
#endif
#endif // __AFXINET_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -