How To Launch CDs with HTML Applications (cont'd)
To create an AutoPlay CD, you include an AUTORUN.INF file in the root directory of the CD in the following format:

   [autorun]
   OPEN=<executable program to run>
   ICON=<icon to show in Windows Explorer>
 
advertisement
If you don't have an icon to display, you can omit the ICON entry. The AutoPlay feature in Windows doesn't call the Win32 ShellExecute() API, so you're limited to .exe, .com or .bat files for the OPEN entry. That's a problem, because you want to launch a .HTA file. Fortunately, the solution is relatively simple—create a short EXE program that calls ShellExecute(). The AUTORUN.EXE program included with the sample calls ShellExecute() for you, so it can launch an HTA file.

The sample AUTORUN.EXE stub program accepts a single command-line argument—the name of the file to run, so if you wanted to the launcher to start an autorun.hta application, your AUTORUN.INF file would look like this:

   [autorun]
   OPEN=autorun.exe autorun.hta
 
If the ShellExecute() function returns an error (as it would if the target computer doesn't have Internet Explorer 5 or greater), the autorun stub opens the CD root directory in Windows Explorer.

Listing 1 shows the the AUTORUN.EXE source code. You don't need a C compiler to use the sample code unless you want to modify the Autorun.exe program itself.


Previous Page: CD Launcher Options Next Page: Launching Different Types of Applications


Page 1: CD Launcher OptionsPage 3: Launching Different Types of Applications
Page 2: The AUTORUN.INF file and Stub ExecutablePage 4: Potential Problems