The CHM file in the VC is mainly used in HTMLHELP functions in HTML Help Workshop SDK.
If you do not have HTML Help Workshop, you can download from the Microsoft website:
Http://msdn.microsoft.com/library/en-us/htmlhelp/html/hwmicrosofthtmlhelpdownloads.asp
The description of the HTMLHELP () function in the HTML HELP API REFERENCE is shown below:
HWND HTMLHELP (HWND HWNDCALLER, LPCSTR PSZFILE, UINT UCOMMAND, DWORD DWDATA);
Parameters / Description HWndCaller Specifies the form handle that calls HTMLHELP (). Help form is the form. After the Help Form is closed, htmlhelp () returns the focus to its own form, except for the form of the desktop. If hwndcaller is a desktop, it is determined by the operating system to return to where. In addition, if htmlhelp () sent any notification message from the Help Form, these messages will also be sent to hWndcaller, which is like you activating the notification message tracking mechanism defined in the Help Form. The PSZFile pszfile parameter depends on the value of Ucommand, which is the specified file path. The file can be compiled .chm file, or one of the specified .hm files (typically .htm or .html). You can also specify a form type name by adding a greater than the number (>), if the command does not request a file, the parameter value can be NULL. Ucommand specifies the completed command. DWDATA specifies any data that may be needed, based on the value of Ucommand parameters.
The return value is based on the value specified by Ucommand, and HTMLHELP () returns one or two values:
1. Help the handle of the form. 2, NULL. In some cases, NULL means failed; in addition, NULL indicates that the help form is not created.
To successfully call the CHM file, you must also join HTMLHELP.H and HTMLHELP.LIB in the VC development environment, the specific steps are as follows:
Project-> Settings (Alt F7).
1. Select PreProcessor in the list of C / C tabs, and fill in the address of HTMLHELP.H in the Additional Include Directories box (for example::
C: / Program Files / HTML HELP WORKSHOP / INCLUDE / HTMLHELP.H). 2. Select Input in the list of Gategory in the Link tab, fill in the address of HTMLHELP.LIB in the AdditionLibrary Path box (for example: C: / Program Files / HTML
Help workshop / lib / htmlhelp.lib). 3. Select General in the list of Gategory's Gategory in the LINK tab, and fill in HTMLHELP.LIB in the Object / Library Modules box.
Suppose you want to call the CHM application as an SDI program, and compile good help files and programs under the same directory. (The CHM file name in the sample code is help.chm, getModuleFileName is used to get the help file path.)
1. Add htmlhelp.h: #include "htmlhelp.h" in stdafx.h: #include "htmlhelp.h". 2, call chm: char szfilepath [max_path], szpath [max_path]; getModuleFileName (null, szfilepath, max_path); // Get the current program directory SIZE_T IPOS = Strlen (Strrchr (Strrchr (SZFILEPATH, '//') ); strncpy (szpath, szfilepath, ipos); strcat (szpath, "// help.chm); HTMLHELP (NULL, SZPATH, HH_DISPLAY_TOPIC, NULL);
More about the HTMLHELP function can be referred to the HTML Help API Reference.