这里简单介绍一种方法:
实现思路:chm格式转html,然后提取html中指定的内容。
1.chm转html:
private void UseCmdFunc(string chmName,string htmlOutPath)
{
Process process = new Process();
// 设置进程启动信息
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe"; // 设置要启动的程序为CMD
startInfo.RedirectStandardInput = true; // 设置重定向输入流
startInfo.UseShellExecute = false; // 设置不使用操作系统外壳程序启动进程
startInfo.CreateNoWindow = true; // 设置不创建窗口
// 启动进程
process.StartInfo = startInfo;
process.Start();
string htmOutPath = htmlOutPath + @"\html" +
chmName.Replace(".chm","").Replace(htmlOutPath, "") + "html";// 输入命令
process.StandardInput.WriteLine($@"hh -decompile {htmOutPath} {chmName}"); // 输入dir命令
// 关闭输入流
process.StandardInput.Close();