Click here to Skip to main content
15,896,912 members
Articles / Programming Languages / C#

The most complete C# Webbrowser wrapper control

Rate me:
Please Sign up or sign in to vote.
4.90/5 (141 votes)
28 May 2007CPOL21 min read 3.1M   40K   511  
A C# (.NET 2.0) control which creates, hosts, and offers advanced customization such as dragdrop, file downloads, HTTP/S header viewing, and much more.
// UrlParts.h: interface for the CUrlParts class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_URLPARTS_H__142A1831_D146_4168_B37B_8DEB367FF92D__INCLUDED_)
#define AFX_URLPARTS_H__142A1831_D146_4168_B37B_8DEB367FF92D__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <wininet.h>

class CUrlParts  
{
public:
	CUrlParts();
	~CUrlParts();

	bool SplitUrl(BSTR bUrl);

	inline INTERNET_SCHEME GetInternetScheme(void) const { return lnScheme; }
	inline LPCTSTR GetScheme(void) const { return szScheme; }
	inline LPCTSTR GetHostName(void) const { return szHostName; }
	inline LPCTSTR GetUserName(void) const { return szUserName; }
	inline LPCTSTR GetPassword(void) const { return szPassword; }
	inline LPCTSTR GetUrlPath(void) const { return szUrlPath; }
	inline LPCTSTR GetExtraInfo(void) const { return szExtraInfo; }
	inline LPCTSTR GetFileName(void) const { return szFileName; }
	inline LPCTSTR GetFileExtension(void) const { return szFileExtension; }

	BSTR GetFileNameAsBSTR(void) const
	{
		CComBSTR m_str1(L"");
		if(dwFileName > 0)
		{
			m_str1.Empty();
			m_str1 = szFileName;
		}
		return m_str1.Copy();
	}

	BSTR GetFileExtensionAsBSTR(void) const
	{
		CComBSTR m_str1(L"");
		if(dwFileName > 0)
		{
			m_str1.Empty();
			m_str1 = szFileExtension;
		}
		return m_str1.Copy();
	}

	inline DWORD GetSchemeLen(void) { return dwScheme; }
	inline DWORD GetHostNameLen(void) { return dwHostName; }
	inline DWORD GetUserNameLen(void) { return dwUserName; }
	inline DWORD GetPasswordLen(void) { return dwPassword; }
	inline DWORD GetUrlPathLen(void) { return dwUrlPath; }
	inline DWORD GetExtraInfoLen(void) { return dwExtraInfo; }
	inline DWORD GetFileNameLen(void) { return dwFileName; }
	inline DWORD GetFileExtensionLen(void) { return dwFileExtension; }
	inline DWORD GetPort(void) { return dwPort; }
	void ResetBuffers();

private:
	bool Allocated;

	LPTSTR szScheme;
	LPTSTR szHostName;
	LPTSTR szUserName;
	LPTSTR szPassword;
	LPTSTR szUrlPath;
	LPTSTR szExtraInfo;
	LPTSTR szFileName;
	LPTSTR szFileExtension;

	DWORD dwScheme;
	DWORD dwHostName;
	DWORD dwUserName;
	DWORD dwPassword;
	DWORD dwUrlPath;
	DWORD dwExtraInfo;
	DWORD dwFileName;
	DWORD dwFileExtension;
	DWORD dwPort;
	
	INTERNET_SCHEME lnScheme;
	
	
	bool AllocateBuffers(int iNum);
};

#endif // !defined(AFX_URLPARTS_H__142A1831_D146_4168_B37B_8DEB367FF92D__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions