Click here to Skip to main content
13,593,234 members
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 25 Mar 2000
Licenced CPOL

How to use the res: protocol in Developer Studio

, 25 Mar 2000
Rate this:
Please Sign up or sign in to vote.
A simple MFC demo application that demonstrates using the res: protocol to use resources in your applications
  • Download demo project - 58 Kb
  • Download exeuctable - 12 Kb
  • Sample Image - Res.gif


    A few days back I heard about a protocol called as the res: protocol in a discussion group. I was soon checking it as to what it meant and how to use, and it had a solution for me to use in my project. My application displays an HTML start page, which I used to un-cleverly extract from my executable before displaying to the user (I didn't intend the user to modify this HTML page afterall). The clean answer to this was to use the res protocol (Mind it this requires IE 4+, which was not a problem for me).

    Now to the details. The resprotocol is quite similar to the http://, ftp:// etc protocols. You might have seen quite a few times this protocol being automatically executed by IE when it has an error. (Eg: The Page not found and other error pages are actually HTML pages in SHDOCLC.DLL displayed by IE using the resprotocol). The about box in IE is also an HTML page in the SHDOCLC.DLL displayed using the ShowHTMLDialog function exposed by IE SDK.

    You could take a quick peek in SHDOCLC.DLL by opening it as a resource in Microsoft Developer Studio.

    A demonstration Application

    The enclosed sample shows a quick peek into using the RES dll and showing the about box using the res protocol and the ShowHTMLDialog function.

    The sample was developed in VC Ver 6.0 and NT 4.0 (Service Pack 5). VC Ver 5.0 onwards supports a new resource type called HTML for HTML file types. In the HTML View class OnInitialUpdate override we call the LoadFromResource to load the start HTML page specified by the resource id. This HTML page contains a GIF file (image7.gif - an html resource that has to be displayed). This resource has to be added in to your resource file under the numeric id 2110 and not "2110" under its file name and that in this example happens to be "image7.gif". (I actually imported this file using import and then copied it into custom numeric resource id 2110.)

    Similary I added the About HTML Start Page. Now a quick tip on invoking the HTML About Dialog using this resource HTML id.

    To display an HTML dialog we could use then use ShowHTMLDialog function declared in <mshtmhst.h>. This function has the following declaration

    HRESULT ShowHTMLDialog(
        HWND hwndParent,
        IMoniker *pMk,
        VARIANT *pvarArgIn,
        WCHAR *pchOptions,
        VARIANT *pvarArgOut

    where hwndParent is your parents HWND and pMk is a pointer to the IMoniker interface pointing to your source URL and can be created using the CreateURLMoniker function.

    HRESULT CreateURLMoniker(
        IMoniker *pmkContext,
        LPWSTR szURL,
        IMoniker **ppmk

    This function is wrapped for ease in to the CHtmlAbout dialog class.


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


    About the Author

    Santosh Rao
    India India
    1993 started with Computers

    BE(Computer Science) and MS (Software Systems)

    Industry Experience: 10 Years

    C, C++, VC++(MFC), .NET, C#, MTS, Queuing, ASP.NET, AJAX, Java, J2EE, SunOne, JMS

    Banking, Insurance & Pension,Health Care

    You may also be interested in...


    Comments and Discussions

    Questionmore details about res: Pin
    Member 1279038112-Oct-16 12:47
    memberMember 1279038112-Oct-16 12:47 
    GeneralMy vote of 5 Pin
    manoj kumar choubey26-Apr-12 21:53
    membermanoj kumar choubey26-Apr-12 21:53 
    GeneralGood article Pin
    Bartosz Wojcik13-Jun-07 6:03
    memberBartosz Wojcik13-Jun-07 6:03 
    GeneralRes question.... Pin
    someone_stuggling_with_res!12-Apr-05 14:35
    membersomeone_stuggling_with_res!12-Apr-05 14:35 
    GeneralAll must read Microsoft KB#220830 Pin
    richiehere7-Oct-04 0:00
    memberrichiehere7-Oct-04 0:00 
    Generalres with DHTML Pin
    one_eddie21-Feb-04 8:26
    memberone_eddie21-Feb-04 8:26 
    General"2110" Type Resources Also Work Pin
    Santosh Rao28-Mar-00 23:54
    sussSantosh Rao28-Mar-00 23:54 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
    Web03-2016 | 2.8.180618.1 | Last Updated 26 Mar 2000
    Article Copyright 2000 by Santosh Rao
    Everything else Copyright © CodeProject, 1999-2018
    Layout: fixed | fluid