Click here to Skip to main content
15,664,808 members
Articles / Web Development / HTML
Posted 6 Mar 2018

Tagged as


21 bookmarked

A Programmable Desktop HTML Help Builder

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
6 Mar 2018CPOL5 min read
A programmable desktop HTML help application in C#

Image 1


It is often desirable for desktop developers to include some sort of local help in order to demystify the use of an application for a user. This is particularly useful when there is no reliable internet connection available. There are a number of commercially available programs which propose to accomplish this, but most are not free. A freestanding, Microsoft HTML Help Workshop, is still available, but no longer is under active development, and works poorly (if at all) on Windows 10 systems. MFC C++ developers, used to be able to click on Context Sensitive Help in the Wizard to implement HTML Help, but as of Visual Studio 2017, this is no longer an option. The current application provides developers with a customizable, freestanding help application patterned after HTML Help Workshop, written entirely in C#, and which works on Windows 10.


For developers who prefer .NET and C# for demonstrating proof of concept desktop applications, whether or not they are intended to ultimately be run via a network, the only user help options are to purchase a subscription to an app, for example, RoboHelp (C) Adobe Systems, or to provide HTML files on a server. While the latter makes it easy to update for all users, not all users have access to internet, or they operate in a network environment that prevents remote server access. It seems apparent that an economically feasible, customizable, locally-based HTML help system should be of considerable value to C# Windows developers.

Using the Code

The THtmlHelp window contains only two major components, a Tab Control, and a Web Browser. The Tab Control contains three pages, a Contents page with a TreeView that lists all the help files, an Index page that contains a list of key words, and a Search page that facilitates searching all of the help files for a particular word. The web browser component is a modified and stripped down version of that obtained from the CodeProject article "Web Browser in C# by Claudia Goga, 20 Feb 2010. The source code contains two separate applications, THelpViewer and KeyWordListBuilder which can be compiled and run separately. The THelpViewer executable is the actual HTML Help Viewer. The downloadable source has only rudimentary pages designed to serve as a template for developers to create their own help pages. In order to do that, a developer must utilize an HTML editor. In this respect, the application is similar to most other HTML help programs. Running THtmlHelp.exe in the correct directory structure will result in the application automatically populating the TabControl TreeView with all of the HTML help files. The Index Page needs to be handled separately in order to provide a list of key words and their respective links to appropriate help files. THtmlHelp.exe will automatically load the IndexData.xml file that contains the necessary information to populate the Index Page. In order to customize the IndexData.xml file, you can either do it by hand, or better yet, use the accompanying KeyWordListBuilder application. The builder app contains some simple instructions and will allow you to add key words and associate them with a particular file, then save the entire list as an XML file. Please note that both THtmlHelp.exe and the IndexData.xml file MUST be placed in the root directory of your application, and that directory MUST also contain the subdirectory 'hlp' which in turn contains all of your help htm files and a subdirectory for images if you choose to utilize any. Note further that the title bar of the THtmlViewer will contain the name of the HTML page as you have named it.

The code below shows how the viewer loads all of the files contained in the target directory, then loads the TreeView and the Browser. This assumes that there are files including a contents.htm in the hlp directory.

// Fields
    public ArrayList arList  = new ArrayList();
    public String Url = string.Empty;
    public String sPath = string.Empty;
    public String sFolderPath = string.Empty;

// Constructor
public Form1()
    sPath = GetFullPathName("hlp/contents.htm");
    Url = "file:///" + sPath;
    int n = sPath.LastIndexOf('\\');
    sFolderPath = Path.GetDirectoryName(sPath);



public void ProcessDirectory(string targetDirectory)
    string[] fileEntries = Directory.GetFiles(targetDirectory);
    foreach (string fileName in fileEntries)

The code below shows how the TreeView is populated.

private void myTreeView()
    string directoryName = GetFullPathName(sPath);
    int n1 = directoryName.LastIndexOf('/');
    int n2 = directoryName.Length;
    directoryName = directoryName.Remove(n1, n2 - n1);
    string yourParentNode = "Contents";

        var txtFiles = Directory.EnumerateFiles(directoryName);
        foreach (string currentFile in txtFiles)
            string fileName = currentFile.Substring(directoryName.Length + 1);
            n1 = fileName.LastIndexOf('.');
            n2 = fileName.Length;
            fileName = fileName.Remove(n1, n2 - n1);
    catch (Exception e)
        MessageBox.Show("Warning: " + e.Message);


Populating the Index Page is facilitated by the accompanying KeywordListBuilder app.

  • Use New, Open, and Save to manage Index Page lists (IndexData.xml).
  • Tools / Add Keyword to add to a list
  • Associate each keyword with a file in the hlp directory
  • Tools / REmove a Keyword to delete a highlighted list element.
  • Save the list as 'IndexData.xml' in the app root directory (see above).

Image 2

With the THtmlHelp.exe in your calling application root directory, together with the necessary accompanying IndexData.xml file and hlp folder, your calling application can use the following code to bring up the help application.

private void contentsToolStripMenuItem_Click(object sender, EventArgs e)
    Process p = Process.Start("THelpViewer.exe");

protected override bool ProcessCmdKey(Keys keyData)
    if (keyData == Keys.F1) 
        Process p = Process.Start("THelpViewer.exe");
        return true;

    // Call the base class
    return base.ProcessCmdKey(keyData);

Points of Interest

It strikes me as odd that Visual Studio no longer supports HTML Help Studio (HTMLS) and developers are left on their own to provide such help. There may exist some work-around to get HTMLS to work properly, but I have been unable to find it. That is why I was compelled to develop this application. Having spent a fair amount of time programming in C++, I have been pleasantly surprised to find how straightforward, efficient, and powerful Visual Studio C# is. While this current effort could use some refinement, perhaps the single best one would be to somehow compress all the necessary help files and the application itself into a single chm-like package. I considered simply zipping all the components together, but quickly realized that there are a number of different zip file formats and accessing the zipped application would not be easy. Additionally, there is undoubtedly a way to facilitate context sensitive help, but this would add considerable complexity to the program.


  • Version 2.2 March 05, 2018


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

Written By
Software Developer PliaTech
United States United States
Software developer with interests in mathematics and statistics, particularly as applied to health care. CTO and founder of PliaTech.

Comments and Discussions

QuestionBad URL Pin
dvptUml26-Dec-18 12:33
dvptUml26-Dec-18 12:33 
QuestionSource URL Pin
Deacs7-Mar-18 1:39
Deacs7-Mar-18 1:39 
AnswerRe: Source URL Pin
Jeff Law7-Mar-18 7:21
Jeff Law7-Mar-18 7:21 
GeneralRe: Source URL Pin
Michael B Pliam7-Mar-18 9:43
Michael B Pliam7-Mar-18 9:43 
QuestionBad URL? Pin
Jeff Law6-Mar-18 21:28
Jeff Law6-Mar-18 21:28 
AnswerRe: Bad URL? Pin
Member 24433066-Mar-18 21:55
Member 24433066-Mar-18 21:55 
GeneralRe: Bad URL? Pin
Jeff Law7-Mar-18 7:20
Jeff Law7-Mar-18 7:20 
SuggestionWhat is it Pin
Member 24433066-Mar-18 10:23
Member 24433066-Mar-18 10:23 
GeneralRe: What is it Pin
Michael B Pliam7-Mar-18 8:40
Michael B Pliam7-Mar-18 8:40 
SuggestionRe: What is it Pin
Member 24433067-Mar-18 11:04
Member 24433067-Mar-18 11:04 
GeneralRe: What is it Pin
Michael B Pliam7-Mar-18 14:34
Michael B Pliam7-Mar-18 14:34 
GeneralRe: What is it Pin
Member 24433067-Mar-18 19:16
Member 24433067-Mar-18 19:16 
Using HTML Workshop I ran into same problem. But that was due to the .hcc file it creates is crap or I am to stupid to use the tool. However the one generated from KEL works on the fly.
HCC Compared[^]

Also make shure "Default Topic" is set in the .hpp, else its starts with same error.

I am on windows 10 too.

This worked for me, maybe you want to test:
-I installed HTML Help Workshop 1.3, it installed but complained I have a newer HTMLHelp already.
-Then I Used KEL CHM Creator (the download OneDirve link is from 2013).
-Started KEL and created a project.
-Supplied the link to HHC.exe in KEL for compiling.
Screenhost of KEL with HHC.exe added[^]
An everything worked.

Microsoft HTML Help Compiler 4.74.8702

Compiling c:\Documents\HTMLHelp\Test Help.chm


Compile time: 0 minutes, 0 seconds
9	Topics
26	Local links
0	Internet links
0	Graphics

Created c:\Documents\HTMLHelp\Test Help.chm, 13,288 bytes
Compression increased file by 2,414 bytes.

Maybe this Diaganostic Tool can help a bit
MJ's Diagnostics - Helpware Wiki - KB[^]

modified 8-Mar-18 4:01am.

GeneralRe: What is it Pin
Michael B Pliam9-Mar-18 17:30
Michael B Pliam9-Mar-18 17:30 
GeneralRe: What is it Pin
Member 244330610-Mar-18 4:15
Member 244330610-Mar-18 4:15 

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.