Building AutoPlay-Enabled CD-ROM Titles and Games

Alex St. John and Jeff Camp

November 1, 1994
Version 1.0

Click to open or copy the files in the AutoPlay sample application for this technical article.

What Is AutoPlay?

CD-ROM–based titles and games are consumer products. Customers use them because they want to, and they expect the experience to be easy and enjoyable. Too often, it isn't.

The purpose of AutoPlay is to make multimedia title installation and configuration under Microsoft® Windows™ 95 virtually as simple as putting a cartridge in a home video game machine. Simply put, AutoPlay notices when the user loads a CD, and immediately launches whatever application is named in the AUTORUN.INF file on that disk. This modest feature will make Windows 95–based multimedia titles and games accessible even to the most electronically challenged consumer. From the consumer's perspective, AutoPlay-enabled CD-ROM based products run themselves.

Running AutoPlay-Enabled Titles Under Windows 95

If a CD-ROM–based product has the Windows 95 logo on it, you know that it is AutoPlay-enabled. To run it under Windows 95, just insert the disc in the CD-ROM drive. The software automatically does the right thing.

Running CD-ROM Titles Under Windows 3.1

With MS-DOS® and Windows 3.1 today, the easiest part of running most titles is paying for them. The hard work begins when you get home:

  1. First, insert the disk in the CD-ROM drive.

  2. Next, read the instructions. (Were they printed on the disk? Oh, sorry; pull the disk out and copy or memorize them.)

  3. Next, use the File Run command in the Program Manager or the File Manager to start the installation program indicated in the directions. Your CD-ROM drive is probably listed as "D:" but not necessarily so.

  4. Follow the installation instructions. The setup program will probably create an icon in the Program Manager to make it easier to run the next time.

  5. Next time you want to run the program, just find the icon in the Program Manager. (Keep looking; it's surely in there somewhere—maybe just covered up. The graphic on the icon probably disappeared last time you restarted Windows, so ignore the graphics and just look at the labels. . .)

  6. Now double-click the icon. (Hold your hand perfectly still or it doesn't work. Oops—you have to put in the disk first. Sorry! Put it in and try again.)

Running CD-ROM Titles Under MS-DOS

You thought running CD-ROMs under Windows 3.1 was tough? Try setting up an MS-DOS–based CD-ROM title without AutoPlay! MS-DOS–based products stand to gain more from implementing AutoPlay than any other single category of CD-based application.

How AutoPlay Works

New 32-Bit Driver Architecture

AutoPlay is functionality enabled by the new 32-bit, protected-mode driver architecture in Windows 95. Because the operating system can now detect the insertion of media in a CD-ROM drive, it has the opportunity to do some intelligent processing whenever this occurs. In Windows 95, whenever a CD is inserted, Windows immediately checks to see if the CD has a PC filesystem. If it does, Windows 95 looks for a file named AUTORUN.INF.

The AUTORUN.INF File

The minimalist AUTORUN.INF file only needs to contain three lines of text:

[autorun]
open=filename.exe
icon=filename.ico

FILENAME.EXE can name any executable to be run when the CD is inserted. Unless a path is specified, Windows 95 looks for FILENAME.EXE in the root of the inserted CD. You can specify a relative path in order to locate FILENAME.EXE in a subdirectory. For example, to run FILENAME.EXE from the FOO directory, use the syntax

open=foo\filename.exe.

This will run the file in the FOO directory on the CD, regardless of whether the user's CD-ROM drive is mapped to D:, E:, or something else entirely. Note that executing a file located in a subdirectory does not change the current directory.

Microsoft recommends that you always use the open= line of the AUTORUN.INF file to launch a "teaser" application—see the following section for details.

The expression "icon=filename.ico" specifies an icon to represent the AutoPlay-enabled CD in the Windows 95 user interface. This feature makes it easy for users to identify the contents of the CD-ROM drive without having to pull out the disk to look. When the drive does not contain an AutoPlay-enabled CD, the system uses a default icon in its place. You can also specify a .BMP, .EXE, or .DLL file on the icon= line. If a file contains more than one icon, specify the icon number that you want. For example, icon=filename.exe,1 would display the second icon from FILENAME.EXE. (The first icon is number 0.)

Note   The icon= line of AUTORUN.INF always executes relative to the directory where AUTORUN.INF is located. If you want to specify an absolute path location for an icon, use the syntax "defaulticon=path".

When users point to an icon in the Windows 95 user interface and click the right mouse button, Windows 95 presents a "short-cut menu" for that icon. If an AUTORUN.INF is present on a CD-ROM, Windows 95 automatically adds "AutoPlay" to the shortcut menu and sets it as the default behavior—double-clicking the icon will execute whatever is specified on the open= line.

You can add additional short-cut menu items for your CD by adding them to the AUTORUN.INF file. To add short-cuts, use the following syntax:

shell\verb\command=filename.exe
shell\verb=Menu Item Name

In the above syntax, "Menu Item Name" is the shortcut menu item that users will see. It can contain spaces and mixed-case letters. To set a keyboard accelerator for the menu item, precede any letter with an ampersand. Use a verb to associate the command and executable using a short name without spaces. Users will not see the verb unless you omit "Menu Item Name" from AUTORUN.INF.

For example, to add the command "Read Me" to the shortcut menu for your product, include the following in AUTORUN.INF:

shell\readit\command=notepad foo\readme.txt
shell\readit=Read &Me

Normally, "AutoPlay" is the default menu item defined for any AutoPlay-enabled disc. If you would like to set a different verb as the default, add the following line to your AUTORUN.INF:

shell=verb

When the user double-clicks on the icon for your disc, the command associated with "verb" is executed.

Suppressing AutoPlay

AutoPlay can be suppressed by holding down the shift key when inserting a CD. This will prevent AUTORUN.INF from being parsed and executed.

Writing Good AutoPlay Applications

AutoPlay is a simple yet tremendously powerful feature. For the AutoPlay feature to work well, it is very important that CD title developers abide by certain conventions to ensure that users have a consistent, positive, and stress-free experience with AutoPlay applications. The conventions are as follows.

Launch a "Teaser" Application to Provide Instant Feedback to the User

It is very important for users to receive virtually instantaneous feedback when they insert an AutoPlay CD. We strongly suggest that you use the "open =" line of the AUTORUN.INF file to launch a small "teaser" .EXE file that loads very quickly. Please note that some CD drives take longer than others to report a disk insertion event to the system—just because it seems fast enough on your machine doesn't necessarily mean that your customers will be so lucky! Small is good.

Give the User a Way Out

The "Teaser" application also allows the user a way to cancel the loading of a title. With a pile of AutoPlay disks sitting on the desk, it is easy to accidentally pop the wrong one in! The teaser applet should put up a dialog that includes, at a minimum, OK and Cancel options. It may also include other options, such as install and uninstall, but the most important features of the teaser are that it (1) responds quickly, (2) clearly identifies the title played, and (3) makes it simple to back out if it was not what the user expected. Here is an example of a very simple "teaser" screen created by Humongous Entertainment for their AutoPlay-enabled Freddi Fish title:

Teaser Screen for Freddi Fish, by Humongous Entertainment

Use a Thread to Load Ahead

Users will probably click "OK" (or, in the above example, "Play") in the teaser screen most of the time. In anticipation of this fact, you may want to take advantage of threading under Windows 95 to begin loading your application into memory in the background even before the user clicks OK. This will significantly reduce the perceived load time for your application.

Don't Hog the Hard Disk

AutoPlay opens a whole new set of distribution possibilities for multimedia titles: Because AutoPlay-enabled titles are so easy to run, they could be rented in the same way as video tapes and game cartridges, and consumers could choose to try and/or buy many of them. To minimize support hassles, retailers should avoid selling or renting PC titles that are "drive hogs." It will be bad for the industry in general if multimedia applications eat up drive space to such an extent that consumers can no longer buy and install additional products. Here's how to avoid the problem:

Use the Registry

The Registry is a feature of Windows 95 and Windows NT that completely replaces the need for .INI or other application configuration files that clutter the file system. Registry manipulation application programming interfaces (APIs) are documented in the Win32® Software Development Kit (SDK).

If your title has installation requirements, use the Registry to store configuration information. This will allow you to use the Teaser application to do the right thing when the user puts your product in the CD-ROM drive:

AutoPlay for MS-DOS Applications

In addition to being a great solution for native Windows multimedia applications and games, AutoPlay can also be extremely useful for MS-DOS–based titles. AutoPlay can be used to install, configure, and run MS-DOS–based applications as easily as it can Windows-based applications. Because each MS-DOS–based application in Windows 95 can be configured with its own unique icon, CONFIG.SYS, and AUTOEXEC.BAT, it is possible to use Windows 95 to intelligently generate correct configuration files for an MS-DOS–based application specifically for the machine it is being installed on. The startup application can then cause the MS-DOS–based application to launch and boot within a window, or even cause Windows 95 to effectively reboot to run it if necessary, and immediately return to Windows when the application closes.

How AUTORUN.INF Behaves on Windows 3.1 and MS-DOS

Because AUTORUN.INF is simply ignored by MS-DOS and Windows 3.1, there is no harm in putting it on titles in preparation for Windows 95. Thus, a Windows 95 AUTORUN.INF and an AutoPlay teaser are wise things to consider for any MS-DOS or Windows title shipping today, if it is anticipated that the product will still be in the market when Windows 95 ships.