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.
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.
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.
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:
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.
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 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.
AutoPlay can be suppressed by holding down the shift key when inserting a CD. This will prevent AUTORUN.INF from being parsed and executed.
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.
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.
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
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.
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:
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:
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.
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.