C # generate a CHM File (using hha. dll in other articles ),
Generally, the default path is C: \ Program Files \ HTML Help Workshop or C: \ Program Files (X86) \ HTML Help Workshop.
To solve this problem, we can use hha. dll to compile the CHM file, which is also done by many CHM generation software.
Hha. dll information is relatively small, because Microsoft has not published hha. dll functions, but there are still a few cool people who have made the functions for us, such as "night smell". This article is based on this.
In fact, its CHM project compiler HHA. DLL provides an export function named HHA_CompileHPP to implement. the CHM project file of hpp is directly compiled, and two callback functions are used to notify the user of the current compilation progress.
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:
String log1; string log2; delegate bool GetInfo (string log); // compilation 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 ");}}}
For simplicity and convenience, we compile the hhp file that has been generated directly (you can use the settings of alexiseditor to remove "delete temporary files ), if you are interested, you can go deeper, such as obtaining compilation progress information and displaying compilation progress ....
C language ^ how to use
A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010
B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011
^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.
//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].
C language ^ how to use
A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010
B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011
^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.
//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].