Click here to Skip to main content
13,900,896 members
Click here to Skip to main content
Add your own
alternative version


14 bookmarked
Posted 24 Aug 2007
Licenced CPOL

The Ultimate Toolbox URL Class

, 25 Aug 2007
Rate this:
Please Sign up or sign in to vote.
A simple URL/UNC composition class from the The Ultimate Toolbox

Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.

Source code and project files for this sample are included in the samples\file\URLDemo directory of the sample projects download.


The COXURL class represents a URL (like the one you use in your Internet browser).

It can divide a URL into different parts or compose a new URL from its parts.

The three parts of a URL are:

  • Protocol
  • Port
  • UNC

The protocol and port are important when using TCP/IP. Another important part is the UNC which can also be used separately.

URL and UNC classes represent a file (or other resource). A full URL (Uniform Resource locator) and a UNC (Universal Naming Convention) supports a new base class for file management functions useful to build applications that conform to the Win95 specifications (which requires UNC support). They are also useful to add internet functionality to your application.

The COXUNC and COXURL classes are simple to use - the samples\file\URLDemo sample simply includes OXURL.h and OXIteratorUNC.h headers and declares temporary objects to parse the string to show the 'splitting' functionality for UNC and URL strings:

void CURLDemoDlg::OnSplitUNC() 
    if (!UpdateData(TRUE))

    UNC = m_sURL_UNC;
    UNC.URLPart() = m_bURLPart;

    m_sServer = UNC.Server();
    m_sShare = UNC.Share();
    m_sDirectory = UNC.Directory();
    m_sFile = UNC.File();
    m_sBaseName = UNC.Base();
    m_sExtension = UNC.Extension();
    m_bURLPart = UNC.URLPart();

The full functionality of the UNC class includes a lot of actions on the actual files or directories like create, delete, rename, move, get directories, and change size, attributes and file times.

void CURLDemoDlg::OnSplitURL() 
    if (!UpdateData(TRUE))

    URL = m_sURL_UNC;

    // Get the result

    m_sProtocol = URL.Protocol();
    m_nPort = URL.Port();
    m_sServer = URL.UNC().Server();
    m_sShare = URL.UNC().Share();
    m_sDirectory = URL.UNC().Directory();
    m_sFile = URL.UNC().File();
    m_sBaseName = URL.UNC().Base();
    m_sExtension = URL.UNC().Extension();
    m_bURLPart = URL.UNC().URLPart();

    // Get the input parameters again 

    m_sURL_UNC = URL;



A complete class reference for the COXURL and COXUNC and related classes is available in the compiled HTML documentation.


Initial CodeProject release August 2007.


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


About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

459 members

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190306.1 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid