# CHMDir Plugin (WCX/WDX) for Total Commander

Switch to Russian

Version 0.41-alpha (x86 and x64). Use it at your own responsibility. If you upgrade plugin, see section History.

WARNING: IN x64 VERSION DON'T WORK PACKING, DELETING ETC. — IT CRACHES TC!
Author uses 32-bit system and have not enough time for testing 64-bit version.

Tested with Total Commander 7.x (32-bit) under WinXP (rus), 8.0 (64-bit) under Win7 (x64). Need WinNT 3.5 or Win95 or newer.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY and NO SUPPORT.

Comments may be send to author.

CHMlib, CHMtools and LZX Compression library are Copyright 2001 Matthew T. Russotto — http://www.speakeasy.org/~russotto/.

CHMDir uses info from Paul Wise aka pabs — http://pabs.zip.to and small piece of code from Info-ZIP (file `match.c`).

- About plugin
- Files in archive
- How to install plugin
  - As packer plugin (WCX)
  - As content plugin (WDX)
- CHMDir.ini — settings
- CHMView.exe
- wtedit.exe and wtdump.exe
- UnCHMw.exe
- New versions
- How to make
- Author
- History

## About plugin

CHMDir adds support of ITSS/CHM file format (compiled HTML) to Total Commander, allows you to extract, search, pack, delete files in CHM.

Also it add unpacking of HtmlHelp 2 files (`.Hx?`).

Also it can used as content plugin, showing info about title of help window, maker of CHM and time of compilation.

Presence of Internet Explorer in system is not necessary.

> NB: Plugin can not make full-fledged HtmlHelp files (contents, index, etc.) but it can make CHM-file even if there is one '.htm' or '.html' file in files to be packed. For example, repack this archive to CHM-file. To make full-fledged HtmlHelp use HTML Help Workshop or htm2chm.

If there is not file '#SYSTEM' in root of packed files list it will be created and if there is not some '.hhc' file in packed list, 'stub.hhc' will be created with all files and directories from packing list using <title> of topic. Its order depends on sort type of TC. Default topic will be (what comes first, case insensitive): see '`default_topics`' in CHMDir.ini. If there is not such file, first found '.htm' or '.html' in packed list will be used.

For keeping structure of file before repacking it must be unpacked with turned on option 'Show special CHM files' in CHMDir.ini to keep files such as '#SYSTEM' (there is information about title of help window and contents file in this file).

## Files in archive

File_Id.diz |  | short description of package
index_en.htm |  | description of package on English (you are now reading)
index_ru.htm |  | same as above on Russian
chmdir.css |  | Style sheet for `index_*.htm`
pluginst.inf |  | INF-file for automatically install the plugin
CHMDir.wcx |  | plugin module
sample.ini |  | sample INI-file for plugin
chmdir.lng |  | language file for WDX
CHMView.exe |  | program for viewing CHM files without `hh.exe`
UnCHMw.exe |  | command line utility for unpacking CHM files
wtdump.exe |  | program for dumping properties of HtmlHelp window
wtedit.exe |  | program for editing HtmlHelp window properties
descript.ion |  | file descriptions

## How to install plugin as WCX

1. Unzip the `chmdir.wcx` to the Total Commander directory (usually `c:\wincmd` or `c:\totalcmd`) or directory as you like
2. In Total Commander, choose Configuration/Options and open Plugins page
3. Click Configure in 'Packer plugins (.WCX)'
4. Type '`chm`' as the extension
5. Click New type, and select the unpacked `chmdir.wcx`
6. Click OK
7. Repeat steps 4-6 for .hxs extension
8. If its necessary make file CHMDir.ini (or copy from `sample.ini`) in dir same as plugin

> NB: File icons and default action (on <Enter>) will not change. To enter into archive use <Ctrl-PgDn>. If you want to change this to opening archive with <Enter> and showing archive icon:
> 1. Choose Configuration/Options... then open page Packer and press button Configure in 'Packer plugins (.WCX)'
> 2. In drop-down list 'All file with...' choose '`chm`'
> 3. In field 'Associate with:' change number NNN before comma to MMM, where MMM=NNN-256

> or

> 1. Close Total Commander
> 2. Open Total Commander's INI-file (usually `<windows_dir>\WINCMD.INI`) with text editor
> 3. In section `[PackerPlugins]` change NNN in line looks like '`chm=NNN,C:\wincmd\chmdir.wcx`' to MMM, where MMM=NNN-256.

> To view CHM-file use one of:

> - command `hh <chm-file>`,
> - keystroke <Ctrl-Enter> to insert file name into command line and <Enter> to open file,
> - right click on file name and choose default action (bolded).

## How to install plugin as WDX

1. Choose Configuration/Options...
2. Choose page Plugins and in group 'Content plugins (.WDX)' press button Configure.
3. In the 'Content plugins' dialog box press Add and type '`*.wcx`' in 'File name' field.
4. Locate unpacked CHMDir.wcx and press Open.

## CHMDir.ini

At startup plugin looks up in its directory (or directory specified by Total Commander) the file `CHMDir.ini` — standard Windows ini-file.

See descriptions in sample.ini.

In order to changes start to work you must restart TC or unload all plugins and change to another archive (TC remember file list of last archive).

NB: To use `CHMDir.ini` from plugin dir, add into INI file into section `[CHMDir]` line `ini_in_plugdir=1`.

## Known bugs and limitations

- Plugin uses CHMTools that deals with version 3 only.
- Plugin uses RAM to hold file names in CHM and for unpacking buffer. So if you have 1000 files in file with 100 bytes average file name length then you need more ~0.5 Mb RAM available.
- Plugin will not work with files >= 2 Gb.

## CHMView.exe

This program is intended for viewing CHM files without hh.exe. It needs one parameter — CHM file name. It will unpack all files in CHM into temp dir and will try to start default HTML viewer.

## wtedit.exe and wtdump.exe

wtdump.exe dumps properties of HtmlHelp window (or default properties in current dir) and sample HHP (HtmlHelp project file) that can be used to create such HtmlHelp.

wtedit.exe allows you to edit HtmlHelp window properties of file that used as program parameter.

Both programs need `CHMDir.wcx` in its directory or in directory pointed by environment variable '`PATH`'.

For more information see HTML Help Web page or Help for HTML Help from HTML Help Workshop.

## UnCHMw.exe

This program is stand alone command line version of CHM unpacker.

UnCHMw.exe uses settings from CHMDir.ini.

## New versions

See: http://www.totalcmd.net/plugring/chmdir.html

## How to make

Edit `Makefile`, make dir with name "obj" and run 'Nmake.exe'.

## Author

Oleg Bondar aka Hobo (`hobo-mts at mail pnt ru`). Change 'at' to '@' and 'pt' to '.'.

Subject of message must contain word '`CHMDir`'.

## History

### 0.41-alpha (2012/04/06)

- Plugin linked with runtime library statically and don't depend on msvcrt.dll.
- Added x64 version.DO NOT USE IT FOR PACKING, DELETING, ETC. (SEE HEADER).

### 0.40g (2007/12/10)

- Fixed error caused crash CHMView.exe when converting .hhc file (table of contents). Thanks Atlan Gnozal for assistance.

### 0.40f (2007/11/29)

- Fixed error caused crash when opening CHM under Win98SE. Thanks Atlan Gnozal for assistance.

### 0.40e (2007/10/16)

- INI file can be stored in plugin dir.

### 0.40d (2007/10/15)

- Fixed bug causing TC crash when getting `<TITLE>` tag data.
- Settings now saved in default ini-file as recommended in "Writing WCX packer plugins", not in the plugin dir. Translation of WCX plugin moved to chmdir.lng.

### 0.40c (2006/10/07)

- Some corrections made in German translation.

### 0.40b (2006/01/05)

- Call of function GetLongPathName() changed to call by pointer (run-time dynamic linking). Old method caused wtedit.exe loading error under Win95 and WinNT4.

### 0.40a (2006/01/02)

- Call of function GetCPInfoEx() changed to call by pointer (run-time dynamic linking). Old method caused plugin loading error under Win95 and WinNT4.

### 0.40 (2005/12/30)

- Added option to set language ID for created CHM file.
- Added storing of date and time of the archive file's last update.
- Backslash to contents etc. files in links in system files changed to forward slash (backslash caused incorrect browsing).

### 0.40 beta 7 (2005/11/22)

- Added HtmlHelp window properties.
- CHMView: added progress dialogs.
- Added wtdump.exe and wtedit.exe.
- Added UnCHMw.exe.
- Added charset conversion for <TITLE> tag.
- Added charset / language field into content plugin.

### 0.40 beta 6 (2005/06/23)

- Added button to add default topic file name.
- Changed 'LZX window size code' to 'LZX window size' in configuration dialog.
- Added packing with IStorage COM interface.
- Added functionality of content plugin (WDX).

### 0.40 beta 5:

- Added unpacking of HxS files.
- Expanded stub.hhc.
- Added INI-file parameter title_stub.

### 0.40 beta 4:

- Fixed an unfortunate misprint in file header (structure size) that steeled through inadvertence.
- Added option to set low priority when packing.

### 0.40 beta 3:

- Fixed: CHMView was not unpacking CHMs with empty dirs containing subdirs only.
- Clicking on button 'Store files by ext.' enables or disables next edit control.
- Now '=.gif' unpacked as '=.gif', not as '_.gif'.
- Changed sorting of directory listing of CHM.

### 0.40 beta 2:

- Code for made listing rewritten.
- Added packer parameters in INI-file.
- Added file sorting by extension before packing and calculation of listing chunk size.
- Added generation of HtmlHelp files.
- Added INI-file parameters: calc_chunk_size, its_use_store, default_topics, sort_dir_by_ext.
- Added dialog to configure plugin.
- Added index.htm in distribution.

### 0.40 beta 1:

- Code for listing and unpacking fully rewritten — improved memory usage and performance.
- Added caching of CHM data.
- Added functions PackFiles(), DeleteFiles() and ConfigurePacker(). GetPackerCaps() now returns 479. If you update plugin you need to reconfigure of plugin (see above).

### 0.30a:

- Added function PackSetDefaultParams() (stub and in source only — plugin makes initialization when DllMain() is called — wrong way but user does not know what INI file is used, and plugin can not inform him about it — all settings made manually by editing INI file)

### 0.30:

- Added function CanYouHandleThisFile() for opening files other then .chm. GetPackerCaps() now returns 452.
- Added CHMView.exe into distribution

### 0.29 beta:

- Added INI-file
- Memory requirements significantly decreased
- Removed make-files for Watcom and lcc-Win32

### 0.28 beta:

- Files with name started with '#' and '$' removed from listing
- Char '_' used as default for unmappable characters in WideCharToMultiByte(). Not tested because I have not that files.
- Yet another kludge for unpacking files made by htm2chm

### 0.27 beta:

- Added processing of returned result of ProcessDataProc() — 'Cancel' button works.
- Fixed error that provoked crash while opening CHMs that contains lo-o-ong file names.

### 0.26 beta:

- Added decoding of file names from UTF-8.

### 0.24 beta:

- Added info about CHMView.
- Time of archive files == time of CHM file.
- Added version info.

### 0.23 beta:

- Return to one .WCX file — no additional DLL.
- Fixed error with memory deallocation in chmdir.
- Kludged (I hope) [error] in Matthew T. Russotto's chmlib that makes access violation in Total Commander. See comment `'!!! Hobo'`.
- Added READMEru.txt — on Russian.
- Archive name changed to wcx_chmdirX.XX.zip.

### 0.22 beta:

- Next try to make stable release. Matthew T. Russotto's chmlib moved to separate DLL and this DLL loaded and unloaded every processed file for decrease memory usage.

  Failed. Known bug #1 still present. :-(

### 0.21 beta:

- Added function GetPackerCaps().

### 0.20 beta:

- First public release.