Programming context-sensitive WebHelp to C and C++ applications

Note: The information in this topic is intended for developers using C and C++ to connect context-sensitive WebHelp to UNIX applications. If your application runs on Microsoft Windows systems, see Context-sensitive WebHelp for Visual C++.

When the author generates the WebHelp output files in RoboHELP, a file called WebHelp.csh is created and saved in the WebHelp output folder. This is a UNIX script file for launching context-sensitive Help on UNIX systems. If your application runs on UNIX, you can use this file to launch the context-sensitive Help files.

WebHelp.csh takes care of mapping a context string to a URL, then launches the browser to display the URL. You can easily modify WebHelp.csh (with a text editor) to add your own context strings.

To invoke WebHelp.csh, you need to fork a new process and execute the script. Here is an example function that invokes WebHelp:

// ShowHelp() returns non-zero for success, 0 for failure
int ShowHelp(const char* szContext)

{

pid_t pidProcess = fork1();
if (pidProcess == 0) {

// this is the new child process
execl("WebHelp.csh", szContext, NULL);

// execl only returns if an error occurred

_exit(-1); // must call _exit(), not exit()

}
else if (pidProcess == (pid_t)(-1)) {

// fork failed, errno is reason

return 0;

}

return 1;

}