ExecProgram (or EP)

Starts an application.

Syntax

ExecProgram("command-line", display-state)

EP("command-line", display-state)

Parameter Description

command-line Command line for the application to be started. The command line must be enclosed in quotation marks.
display-state Specifies a value indicating how the application is shown when started.

ValueDisplay

0Normal

1Minimized

2Maximized


Example

The following macro runs the Clock program in its normal window size:

ExecProgram("clock.exe", 0)

Comments

When using this macro to start an application, Windows Help searches for the application in this order: the current directory, the Windows directory, the Windows SYSTEM directory, the user’s path, and then the directory of the currently displayed Help file.

The ExecProgram macro does not change the directory before starting an application, so if you need to set the working directory for the application so that Help can find the correct files, you must create your own custom DLL.

If your application includes an online tutorial, you can use the ExecProgram macro to create hot spots within the Help file that link to tutorial lessons. For example, the following macro starts the TUTOR.EXE tutorial application (located in the LESSONS subdirectory) and displays the Toolbox lesson in a maximized window:

ExecProgram("c:\\lessons\\tutor.exe toolbox.cbt", 2)

The ExecProgram macro converts display-state values into the appropriate ShowWindow values. However, some applications may ignore the display-state you specify (because they ignore the nCmdShow parameter). For example, some tutorial applications may operate only in a maximized window; therefore, the value you specify in the display-state parameter may or may not work. To test whether an application ignores these values, hold down the SHIFT key while double-clicking the application’s icon in Program Manager. If the application starts minimized, it will probably accept the value you specify. If the application starts in any other state, it will ignore the display-state value.

If you must use quotation marks as part of the command-line parameter, you can enclose the entire parameter in single quotation marks and omit the backslash escape character required for the double quotation marks delimiting the string, as shown in this example:

ExecProgram(`command "string as parameter"', 0)