In the C # CHM File generation series, we use the hhc that comes with Microsoft.Exe to compile the CHM file,In this case, there is a zookeeper. When we do not have hhc.exe installed in our machine, we willErrors, which are usually common in Pirated Windows systems, while genuine wiNdowswill help us install hhc.exe. The general default path is C: Program FilesHTML Help Workshop or C: Program Files (X86) HTML Help Workshop.
To solve this problem, we can use hha. dll to compile the CHM File.This is also done by many CHM generation software.
There is little information about hha. dll on the Internet, because Microsoft has not published hha. Dll functions, but there are still a few cool people who have made the functions available to us,For example, "night smells fragrant", this article is based on this.
In fact, the HHA. DLL in its CHM project compiler provides the HHA _The export function of CompileHPP implements the CHM project of. hpp.Directly compile the file, and notify the user of the current compilation progress through two callback functions.
The following is a prototype of HHA_CompileHPP.
Bool winapi HHA_CompileHHP (PCSTR pszHhpFile, FARPROC pLogString, FARPROC pProgress, INT nRes );
We can use DllImport to call functions in hha. dll.
The main code is as follows:
Code String log1;
String log2;
Delegate bool GetInfo (string log );
// Compile information
Public bool GetInfo1 (string log)
{
Log1 = log;
Return true;
}
// Progress information
Public bool GetInfo2 (string log)
{
Log2 = log;
Return true;
}
[DllImport ("hha. dll")]
Private extern static void HHA_CompileHHP (string hhpFile, GetInfo g1, GetInfo g2, int stack );
Public void Compile ()
{
Using (OpenFileDialog ofd = new OpenFileDialog ())
{
Ofd. Filter = "CHM project file | *. hhp ";
Ofd. ShowDialog ();
If (ofd. FileName! = "")
{
HHA_CompileHHP (ofd. FileName, GetInfo1, GetInfo2, 0 );
MessageBox. Show ("compiled successfully ");
}
}
}