惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
I
InfoQ
H
Help Net Security
大猫的无限游戏
大猫的无限游戏
L
LangChain Blog
F
Full Disclosure
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
博客园 - Franky
IT之家
IT之家
K
Kaspersky official blog
Simon Willison's Weblog
Simon Willison's Weblog
C
Cisco Blogs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
Know Your Adversary
Know Your Adversary
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
P
Proofpoint News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The Last Watchdog
The Last Watchdog
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
博客园 - 司徒正美
G
Google Developers Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
Help Net Security
Help Net Security
S
Secure Thoughts
有赞技术团队
有赞技术团队
P
Privacy International News Feed
S
Schneier on Security
T
Troy Hunt's Blog
T
The Blog of Author Tim Ferriss
阮一峰的网络日志
阮一峰的网络日志
H
Heimdal Security Blog
Latest news
Latest news
S
Security @ Cisco Blogs
博客园 - 聂微东
The Hacker News
The Hacker News
B
Blog
Forbes - Security
Forbes - Security
A
About on SuperTechFans
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
罗磊的独立博客
雷峰网
雷峰网

博客园 - Mossan

UltraVNC 简体中文版 1.3.6(Win7以上系统) UltraVNC 简体中文版 1.2.4(WinXP最终版) 数据比较1.0(文本格式) 二代身份Zheng复印(手机正反面拍照生成1:1复印件图像) ownCloud安卓android客户端版本2.11.0 旧手机作为USB无线网卡使用(分享WIFI、蓝牙连接) 计算机开关损坏无法正常启动维修 限时授权复制文件 1.0(2015.9.2更新) Mysql自动备份工具1.0(2013年11月15日更新) Microsoft .NET Framework 3.5 Service Pack 1(完整软件包) 汶川地震感悟 C#模拟键盘登录网站 UltraBackup 1.5.1(2025-01-15更新) LanContain 1.2.2.3(2025-1-15更新) 利用c#开发一个telnet unix服务器或者防火墙的小工具(转) 微软推在线版Office可储存1000个Word文档 Fckeditor XML Request error:internal server error (500) 一例 网络管理员升级版LanContain(Web)源代码 蚂蚁
用C#实现将HTML文件转换为CHM文件(转)
Mossan · 2008-03-07 · via 博客园 - Mossan

这些天因为工作需要,要将一些html文件转换为chm文件,当然是需要和程序结合在一起。
后来找到NDoc,里头有一段代码是相关的,于是开始分析代码,写完之后,总结:主要是利用微软的hhc.exe来编译html文件,程序需要将具体的数据写入hhp和hhc文件。
主要代码如下:
复制C#代码保存代码public void CompileProject()
{
    Process helpCompileProcess = new Process();  //创建新的进程,NDOC采用Process启动HHC.EXE来Compile一个CHM文件

    try
    {
        ////判断文件是否存在并不被占用
        try
        {
            string path = _chmFile;  //chm生成路径

            if (File.Exists(path))
            {
                File.Delete(path);
            }
        }
        catch
        {
            throw new Exception("文件被打开!");
        }

        ProcessStartInfo processStartInfo = new ProcessStartInfo();
        processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
        processStartInfo.FileName = hhcFile;  //调入HHC.EXE文件 
        processStartInfo.Arguments = "\"" + Path.GetFullPath(GetPathToProjectFile()) + "\"";//获取空的HHP文件

        helpCompileProcess.StartInfo = processStartInfo;

        //开始生成....
        helpCompileProcess.Start();

        helpCompileProcess.WaitForExit(); //组件无限期地等待关联进程退出

        if (helpCompileProcess.ExitCode == 0)
        {
            MessageBox.Show(new Exception().Message);
        }

    }
    finally
    {
        helpCompileProcess.Close();
    }
}
public void OpenProjectFile()
{
    FileStream fs = new FileStream(GetPathToProjectFile(), FileMode.Create);
    streamHtmlHelp = new System.IO.StreamWriter(fs, System.Text.Encoding.GetEncoding("GB18030"));
    streamHtmlHelp.WriteLine("[FILES]");
}
public void AddFileToProject(string filename)
{
    streamHtmlHelp.WriteLine(filename);
}
public void CloseProjectFile(string title)
{
    streamHtmlHelp.WriteLine();
    streamHtmlHelp.WriteLine("[OPTIONS]");
    streamHtmlHelp.WriteLine("Title=" + title);
    streamHtmlHelp.WriteLine("Compatibility=1.1 or later");
    streamHtmlHelp.WriteLine("Compiled file=" + GetCompiledHtmlFilename());  //chm文件名
    streamHtmlHelp.WriteLine("Contents file=" + GetContentsHtmlFilename());  //hhc文件名
    streamHtmlHelp.WriteLine("Default topic=" + _defaultTopic);  //默认页
    streamHtmlHelp.WriteLine("Display compile progress=No"); //是否显示编译过程
    streamHtmlHelp.WriteLine("Language=0x804 中文(中国)");  //chm文件语言

    streamHtmlHelp.WriteLine();
    streamHtmlHelp.WriteLine("[INFOTYPES]");

    streamHtmlHelp.Close();
}
转自:http://www.cnblogs.com/monthkey/archive/2004/06/15/15995.aspx