我试图通过在C++中使用系统调用在特定页面/主题上打开.chm文件(Windows帮助文件)。使用命令行参数在特定页面/主题打开.chm文件
我可以通过以下代码成功打开.chm文件到开始页面,但是如何打开.chm文件到帮助文件中的特定页面/主题?
system("start c:/help/myhelp.chm");
PS:我知道系统是邪恶/灰心了,但系统的一部分是不是真的有关它的命令行参数我通过与.chm文件(将指定我想打开的页面),我我试图确定。
我试图通过在C++中使用系统调用在特定页面/主题上打开.chm文件(Windows帮助文件)。使用命令行参数在特定页面/主题打开.chm文件
我可以通过以下代码成功打开.chm文件到开始页面,但是如何打开.chm文件到帮助文件中的特定页面/主题?
system("start c:/help/myhelp.chm");
PS:我知道系统是邪恶/灰心了,但系统的一部分是不是真的有关它的命令行参数我通过与.chm文件(将指定我想打开的页面),我我试图确定。
确定的参数是像这样:
system(" /Q /E:ON /C HH.EXE ms-its:myChm.chm::myPageName.htm");
感谢您发布此的langauge独立的解决方案。在Python中,'subprocess.Popen(“hh,exe ms-its:C:/path/x.chm ::/dir/pg.html”)效果很好,我可能会在Windows上使用它来显示闲置帮助。我很好奇你是否知道'/ Q/E:ON/C'标志应该做什么。 –
在HtmlHelp.h文件中,Windows SDK中有一个名为HtmlHelp的API。你可以像这样调用 - HtmlHelp(GetDesktopWindow(),L“C:\ helpfile \ ::/helptopic.html”,HH_DISPLAY_TOPIC,NULL);
另一种选择 - 使用ShellExecute。微软的帮助并不好用。这种方法更容易,符合你的问题。以下是打开帮助文件并传递身份证号码的快速例程。我刚刚建立了一些简单的字符的,所以你可以看到正在发生的事情:
void DisplayHelpTopic(int Topic)
{
// The .chm file usually has the same name as the application - if you don’t want to hardcode it...
char *CmndLine = GetCommandLine(); // Gets the command the program started with.
char Dir[255];
GetCurrentDirectory (255, Dir);
char str1[75] = "\0"; // Work string
strncat(str1, CmndLine, (strstr(CmndLine, ".exe") - CmndLine)); // Pull out the first parameter in the command line (should be the executable name) w/out the .exe
char AppName[50] = "\0";
strcpy(AppName, strrchr(str1, '\\')); // Get just the name of the executable, keeping the '\' in front for later when it is appended to the directory
char parms[300];
// Build the parameter string which includes the topic number and the fully qualified .chm application name
sprintf(parms,_T("-mapid %d ms-its:%s%s.chm"), Topic, Dir, AppName);
// Shell out, using My Window handle, specifying the Microsoft help utility, hh.exe, as the 'noun' and passing the parameter string we build above
// NOTE: The full command string will look like this:
// hh.exe -mapid 0 ms-its:C:\\Programs\\Application\\HelpFile.chm
HINSTANCE retval = ShellExecute(MyHndl, _T("open"), _T("hh.exe"), parms, NULL, SW_SHOW);
}
的主题是您的.chm文件中的编号。我为每个主题设置了一个#define,因此如果必须更改.chm文件,我可以将包含文件更改为匹配,而不必担心通过代码搜索硬编码值。
这个链接看看:http://www.help-info.de/en/Help_Info_HTMLHelp/hh_command.htm – Naveen