It's difficult to answer because we have not so much information how you are using topicIDStr. Having formatted contextID numbers like shown in my article Creating Context-Sensitive Help for Applications you may check the number range by code.
But again, you have to check all ´topicID's´ while developing your application and authoring your help file. Many things are depending on how help is called from your application.
You may know, the purpose of the two files (ALIAS and MAP) is to ease the coordination between developer and help author (see link above). The mapping file links an ID to the map number - typically this can be easily created by the developer and passed to the help author. Then the help author creates an alias file linking the IDs to the topic names. One can check this externally by FAR HTML. FAR HTML is a toolbox full of various authoring, file and HTML utilities.
Please remember HTMLHelp is about 20 years old and written in C++ by Ralph Walden. The .NET (e.g. VB or C#) Help class is a wrapper for good old HTMLHelp API calls and a quick and dirty coding by Microsoft programmers for managed code. Unmanaged code is the man's way and a second (difficult) solution.
So, when you really want to go deeper into this I'd give some links and information as a starting point. But you have to code for your needs by yourself.
How to use the unmanaged HTML Help API from a managed Visual C# application
Connecting HTML Help to C++/MFC Programs (PDF)
The HH_GET_LAST_ERROR command refers to a missing file Hherror.h which can be found in the following Microsoft KB article.
The HtmlHelp.h file has a comment with HH_GET_LAST_ERROR that say "not implemented" however it appears it is at least partially implemented. If I call HtmlHelp(0, PChar(mHelpFile), HH_HELP_CONTEXT, 911); where 911 is an invalid ContextID, then HH_GET_LAST_ERROR returned Error 0x8004020A with Description text "The compiled help (.chm) file does not contain context IDs."
For most types of errors HH_GET_LAST_ERROR appears to return 0x80004005 "Unspecified error".
As an idea only please have a look at:
LoadLibrary on OCX file fails in Windows 7 x64
As mentioned by others you may check for e.g. File.Exists and shown in the code sample below for a Process.Start(...)
call.
private void button1_Click(object sender, EventArgs e)
{
string helpFilePath = Application.StartupPath + @"\help-subfolder\C-Sharp-CHM-example.chm";
// Verify if the file exists
if (File.Exists(helpFilePath))
{
Process.Start(helpFilePath);
}
else
{
Console.WriteLine(string.Format("File not found [{0}]", helpFilePath));
}
}
Help.ShowHelp
throws exceptions if an argument is bad, or there are permission issues. If you place the call inside of atry
/catch
you should be able to detect if there is an exceptional case. – Balladmonger