C # generate a CHM File (use hha. dll in other articles)

Source: Internet
Author: User

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 ");
}
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.