问题
I want to write CHM viewer in C#. What resources/information could help me do that?
回答1:
I have written a chm viewer, in C++, as part of SumatraPDF (http://blog.kowalczyk.info/software/sumatrapdf/free-pdf-reader.html). It's open-source so you could port the code to C# (http://code.google.com/p/sumatrapdf/).
There are just a few parts to chm reader:
- parse CHM file format, extract *.html pages and other files inside CHM file. In Sumatra we use use CHMLib (http://www.jedrea.com/chmlib/) but there are other libraries (http://bonedaddy.net/pabs3/code/#hhm)
- display .html pages, which is very easy in C#/.NET by using a web browser control
- there are additional features you might want to implement like table of contents. Table of contents requires parsing out a CHMindex file and building a tree view with nodes (you can look at http://code.google.com/p/sumatrapdf/source/browse/trunk/src/ChmEngine.cpp for how we do it in Sumatra)
回答2:
It probably won't be too difficult. You can take a look at this http://savannah.nongnu.org/projects/chmspec which is a good guess at the chm file format as microsoft have never released the official spec. On the surface it is basically a collection of zipped html files. Once unzipped you could open the html files in an embedded browser control. The normal browser control is IE based but there are projects underway to create chrome and firefox embeddible controls.
来源:https://stackoverflow.com/questions/3270455/c-sharp-writing-a-chm-viewer