Thursday, October 22, 2009

Autoplay at CD-ROM

AutoPlay

AutoPlay is for CD-ROM-based titles and games - most often 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-98

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.

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 file system. If it does, Windows 95 looks for a file named
AUTORUN.INF.

The AUTORUN.INF File

The minimalist AUTORUN.INF file need contain only 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 disc 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 right-click, Windows 95 presents a shortcut
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 behaviordouble-clicking the icon will execute whatever is
specified on the open= line.

You can add additional shortcut-menu items for your CD by adding them to the AUTORUN.INF file. To add shortcuts, 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 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. Several of 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 disks
sitting on a desk, it is easy to accidentally pop in the wrong one! The teaser applet should put up a dialog box
that includes, at 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 responds quickly, clearly identifies the
title played, and makes backing out a simple step for the user.

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 are video tapes and game
cartridges. 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't install additional products. To avoid that problem:

If possible, run from the CD directly, without running any installation program.

If your title has installation requirements that must use the hard drive, it should install only the functional
components necessary to execute the title and should provide complete uninstall options for those components.

If you want to use the drive as a temporary or permanent data cache, provide the user with options in the teaser
application that will enable the cached data to be discarded when quitting the title or game.

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.

No comments: