调用HHA_CompileHHP编译chm工程
2007-01-30 13:00
183 查看
调用HHA_CompileHHP编译chm工程
编译chm工程(.hhp)有两种方法:
1.调用hhc.exe
2.调用HHA_CompileHHP
调用hhc.exe编译,代码如下:
// strChmFileName为你的hhp文件的长文件名
CString strCmdLine;
strCmdLine = "hhc.exe ";
strCmdLine += strChmFileName;
WinExec(strCmdLine, SW_SHOWNORMAL);
用这种方法调用,有很多缺点,首先,没有编译进度,没有任何提示,根绝我的测试,还不支持有空格的文件名
一般专业的chm制作软件都是调用的hha.dll中的HHA_CompileHHP函数进行编译
我们这里不讨论如何生成chm的工程文件,这个可以参考Html Help WorkShop生成的文件
调用HHA_CompileHHP,微软没有提供函数声明,也没有提供帮助信息。(据说要和微软签订协议,才可以拿到函数声明及相关的头文件)
参考了网上一篇介绍用delphi实现函数调用的文章,加上我的一点试验,终于我VC实现了
ok,看看我是怎么实现的
先说下HHA_CompileHHP的参数:
(const char*, LPVOID, LPVOID, int)
第一个参数为你要编译的hhp文件名
第二个参数是编译日志回调函数
第三个参数是编译进度回调函数
第四个参数不知道什么用,我把他置为0
开始写代码了
// 下面是两个回调函数的声明
BOOL CALLBACK FunLog(char* pstr);
BOOL CALLBACK FunProc(char* pstr);
//
// CompileHHP
// 调用HHA_CompileHHP编译chm工程
// 参数:pzFileName为待编译hhp文件名
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
////////////////////////////////////////////////////////////////////////////////////
void CompileHHP(char* pzFileName)
{
HINSTANCE hinstLib;
typedef BOOL (WINAPI *MYFUNC)(const char*, LPVOID, LPVOID, int);
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
MYFUNC ProcAdd = NULL;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("hha.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYFUNC) GetProcAddress(hinstLib, "HHA_CompileHHP");
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
{
ProcAdd(pzFileName, FunLog, FunProc, 0);
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method/n");
}
//////////////////////////////////////////////////////////////////////////////////////
//
// FunLog()
// 编译日志回调函数
// 参数:日志字符串
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
////////////////////////////////////////////////////////////////
BOOL FunLog(char* pstr)
{
ASSERT(pstr);
CString strMsg;
strMsg.Format("%s", pstr);
// AfxMessageBox(strMsg);
return true;
}
//////////////////////////////////////////////////////////////
//
// FunProc()
// 编译进度回调函数
// 参数:进度字符串
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
//////////////////////////////////////////////////////////////
BOOL FunProc(char* pstr)
{
ASSERT(pstr);
CString strMsg;
strMsg.Format("%s", pstr);
// AfxMessageBox(strMsg);
return true;
}
//////////////////////////////////////////////////////////////
wuhran@126.com
http://blog.csdn.net/wuhuiran
上面的测试代码在VC6.0+WIN2003下编译通过
请确保你的系统目录或程序当前目录下存在hha.dll文件
编译chm工程(.hhp)有两种方法:
1.调用hhc.exe
2.调用HHA_CompileHHP
调用hhc.exe编译,代码如下:
// strChmFileName为你的hhp文件的长文件名
CString strCmdLine;
strCmdLine = "hhc.exe ";
strCmdLine += strChmFileName;
WinExec(strCmdLine, SW_SHOWNORMAL);
用这种方法调用,有很多缺点,首先,没有编译进度,没有任何提示,根绝我的测试,还不支持有空格的文件名
一般专业的chm制作软件都是调用的hha.dll中的HHA_CompileHHP函数进行编译
我们这里不讨论如何生成chm的工程文件,这个可以参考Html Help WorkShop生成的文件
调用HHA_CompileHHP,微软没有提供函数声明,也没有提供帮助信息。(据说要和微软签订协议,才可以拿到函数声明及相关的头文件)
参考了网上一篇介绍用delphi实现函数调用的文章,加上我的一点试验,终于我VC实现了
ok,看看我是怎么实现的
先说下HHA_CompileHHP的参数:
(const char*, LPVOID, LPVOID, int)
第一个参数为你要编译的hhp文件名
第二个参数是编译日志回调函数
第三个参数是编译进度回调函数
第四个参数不知道什么用,我把他置为0
开始写代码了
// 下面是两个回调函数的声明
BOOL CALLBACK FunLog(char* pstr);
BOOL CALLBACK FunProc(char* pstr);
//
// CompileHHP
// 调用HHA_CompileHHP编译chm工程
// 参数:pzFileName为待编译hhp文件名
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
////////////////////////////////////////////////////////////////////////////////////
void CompileHHP(char* pzFileName)
{
HINSTANCE hinstLib;
typedef BOOL (WINAPI *MYFUNC)(const char*, LPVOID, LPVOID, int);
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
MYFUNC ProcAdd = NULL;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("hha.dll");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYFUNC) GetProcAddress(hinstLib, "HHA_CompileHHP");
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
{
ProcAdd(pzFileName, FunLog, FunProc, 0);
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("message via alternative method/n");
}
//////////////////////////////////////////////////////////////////////////////////////
//
// FunLog()
// 编译日志回调函数
// 参数:日志字符串
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
////////////////////////////////////////////////////////////////
BOOL FunLog(char* pstr)
{
ASSERT(pstr);
CString strMsg;
strMsg.Format("%s", pstr);
// AfxMessageBox(strMsg);
return true;
}
//////////////////////////////////////////////////////////////
//
// FunProc()
// 编译进度回调函数
// 参数:进度字符串
// 作者:吴会然(wuhran@126.com)
// blog: http://blog.csdn.net/wuhuiran
//////////////////////////////////////////////////////////////
BOOL FunProc(char* pstr)
{
ASSERT(pstr);
CString strMsg;
strMsg.Format("%s", pstr);
// AfxMessageBox(strMsg);
return true;
}
//////////////////////////////////////////////////////////////
wuhran@126.com
http://blog.csdn.net/wuhuiran
上面的测试代码在VC6.0+WIN2003下编译通过
请确保你的系统目录或程序当前目录下存在hha.dll文件
相关文章推荐
- 用makefile脚本方式调用vs 2010 的nmake来编译工程的实例
- Ubutnu系统下用QT等IDE调用Caffe、SSD框架,编译Caffe实现分类检测等工程应用的方法
- [转]用makefile脚本方式调用vs 2010 的nmake来编译工程的实例
- Ubuntu系统下实现Android工程调用独立编译的C++程序和GMP、PBC库
- AS3工程中调用C++编译的swc库教程
- Ubuntu系统下实现Android工程调用独立编译的C++程序和GMP、PBC库
- .NET工程中以 C 和 C++ 两种方式编译时,函数调用注意事项
- vc++工程中添加lua代码调用-编译lua静态库文件
- Quartus II 同一工程下编译不同实体,编译两个对等互补调用的模块
- CMake 工程调用 Makefile 编译项目
- Swift工程调用含有FMDB的Framework编译报错的解决方法
- VC6.0编译DLL,使用VS2010调用问题及解决方法
- UPX3.07最简可编译源码【附VS2010工程】
- windows配置caffe及matlab/python接口编译和调用(cpu/gpu)
- eclipse创建的android maven工程使用ant编译,最后在studio里打开使用
- Android工程的编译过程
- 在C++ 程序中调用被 C编译器编译后的函数,为什么要加 extern “C”声明?
- Visual Studio 2010编译时总是提示"调用目标发生了异常"的解决
- STM32工程编译后TIM1时钟变慢的解决
- keil编译STM32工程时 #error directive: "Please select first the target STM32F10x device used in your application (in stm32f10x.h file)"