AutoPlay

From Wikipedia, the free encyclopedia
Jump to: navigation, search
AutoPlay in Windows Vista.

AutoPlay, a feature introduced in Windows 98, examines newly discovered removable media and devices and, based on content such as pictures, music or video files, launches an appropriate application to play or display the content.[1] It is closely related to the AutoRun operating system feature. AutoPlay was created in order to simplify the use of peripheral devices – MP3 players, memory cards, USB storage devices and others – by automatically starting the software needed to access and view the content on these devices. AutoPlay can be enhanced by AutoPlay-compatible software and hardware. It can be configured by the user to associate favourite applications with AutoPlay events and actions.

Overview[edit]

AutoPlay on DVD insertion

When a user inserts a CD-ROM into a drive or attaches a USB camera, Windows detects the arrival and starts a process of examining the device or searching the medium. It is looking for properties of the device or content on the medium so that AutoPlay can present a set of meaningful options to the user. When the user makes a particular choice, they also have the option to make that selection automatic the next time Windows sees that content or device.[2]

The dialog shows the result of a user placing a DVD into a DVD reader, in this case the D: drive. AutoPlay has determined that content is most likely a DVD movie and presents a set of actions to the user based on that decision. These actions are called Handlers and there are sets of Handlers associated with various types of content. The user can now make their decision and click OK to proceed. However, if they also tick the "Always do the selected action" tick box at this point, they will not be prompted the next time that particular content type is seen on that particular drive; the selected application will automatically start.

AutoPlay properties[edit]

The AutoPlay tab on a DVD drive properties dialog

If a user regrets that decision or wishes to make automatic AutoPlay selections for any particular content type, the AutoPlay properties for any drive are accessible through the My Computer desktop icon. Selecting a drive and then "File/Properties" from the Windows Explorer menu, followed by the selecting the AutoPlay tab, gives a dialog similar to that shown. The content types can be selected with the drop down box. Here the dialog shows the Handlers available if AutoPlay ever determines the content type on drive D: to be "Pictures". Selecting an action to perform makes that action automatic for that user. Selecting "Prompt me each time to choose an action" deletes any association; AutoPlay will prompt the next time.

The content types available vary with the type of drive selected. Pictures, Music files and Video files are available with any drive. DVD and CD drives can also have "Music CD" or "DVD movie" and Windows Vista adds others like "Video CD movie" to the list.

Mixed content[edit]

"Mixed content" is the result of file content types falling into more than one of the Pictures, Music files or Video files content types. Note that a CD containing audio tracks is always considered to be a "Music CD" by Windows, regardless of the presence of data tracks.[3] Therefore a CD with Picture files, Video files and audio tracks is a "Music CD"; it is not "Mixed content".

If this is the result of the AutoPlay decision, the user is always presented with the AutoPlay dialog. This will contain a selection of applications deemed appropriate for the content found. Thus if Music files and Video files are both discovered on a flash drive, the user will get to choose from the Handlers for "Music files" along with the Handlers for "Video files". In this case, the user cannot make their selection the default one.

However, the AutoPlay properties dialog for any drive usually gives "Mixed content" as a content type option. The options available here are limited to actions that can handle any type of files, usually "Open folder to view files" is the only Handler listed here. This enables the user to make that action the default for Mixed content.

Devices that are not drives[edit]

The AutoPlay dialog on a non-volume device

Certain types of devices do not appear as drive letters in "My Computer". These are called non-volume devices and AutoPlay handles them somewhat differently from volume devices like CDs and DVDs. Many digital cameras and video devices fall into this category.

As Windows cannot examine the files on the device to determine content type, it is left to the manufacturer to decide how to proceed. A manufacturer can register Handlers against their particular device, can add their device to a group of devices (e.g.: ZipDrives) or allow a device class (e.g.: all devices which are Video Cameras) to handle their device for them. This determines which Handlers will be listed in the AutoPlay dialog when their device is discovered.

The tray icon for a non-volume device

As these type of devices do not have a drive letter, AutoPlay properties cannot be accessed and changed through "My Computer". However, when a device is attached, the discovery causes Windows to place an icon in the taskbar notification area (commonly referred to as the tray). AutoPlay preferences for this device can now be changed by clicking this icon. The image to the left shows the icon that appeared when a video camera was attached.

Default settings[edit]

On a new installation of Windows, a default set of handler applications are registered with the AutoPlay system.[2] The following are the defaults with Windows XP SP2. The Action and Provider are simply strings stored within the Handler, they can vary to give the user a better idea of what will happen if they choose that action. They can also change to suit a user's preferred language. Many Handlers use the same Windows application; for example, Windows Media Player is used to play Music files as well as DVD movies. The word "using" is added by AutoPlay to join the two strings neatly.

Content Action Provider
Music files Play Windows Media Player
Open folder to view files Windows Explorer
Pictures Copy pictures to a folder on my computer Microsoft Scanner and Camera Wizard
View a slideshow of the images Windows Picture and Fax Viewer
Print the pictures Photo Printing Wizard
Open folder to view files Windows Explorer
Video files Play Windows Media Player
Open folder to view files Windows Explorer
Mixed content Open folder to view files Windows Explorer
Music CD Rip music from CD Windows Media Player
Play audio CD Windows Media Player
Open folder to view files Windows Explorer
DVD movie Play DVD movie Windows Media Player
Open folder to view files Windows Explorer

Windows 95 and Windows 98[edit]

Windows 95 and Windows 98 do have a primitive version of AutoPlay. Its sole job is to deal with Audio CDs and Movie DVDs and start an application to deal with them. If the new arrival does not fall into one of these categories Windows proceeds with the usual AutoRun process.[4]

Explorer Folder Options dialog

The action taken with Audio CDs and Movie DVDs essentially considers both types of media as if they were files; Explorer then simply performs the default action associated with that file type. File types and the actions associated with them can be viewed and changed from within any Explorer folder from the "File Types" tab of the "Tools/Folder Options" menu. They are stored in the Registry under HKEY_CLASSES_ROOT.

If the CD is a Red Book standard format Audio CD, then Explorer calls the default action registered for the AudioCD file type. This is normally set to "Play" and commonly calls cdplayer.exe.[5]

If the DVD is a Movie DVD then Explorer calls the default action registered for the DVD file type. Movie DVDs are recognised by the existence of the file \video_ts\video_ts.ifo. The action for DVD is also normally set to "Play" and commonly calls dvdplay.exe.

The fact that the check for Audio CDs and Movie DVDs is done before AutoRun has implications for disabling the automatic playing of these types of media. Disabling AutoRun via the Registry or Group Policy or looking for QueryCancelAutoPlay messages within an application does not prevent these media types from automatically playing on insertion.[6]

However one can disable Audio CDs by editing the file type for AudioCD and clicking "Set default". This will remove the Play action as the default for that file type. Alternatively, changing the (Default) entry under the HKEY_CLASSES_ROOT\AudioCD\Shell key to "" (a blank string) will accomplish the same thing. The disabling action for Movie DVDs is the same, with "DVD" used in place of "AudioCD".

The pertinent Registry settings are shown below along with their defaults in Windows 98SE:

HKEY_CLASSES_ROOT\AudioCD\shell
    (Default)    "Play"

HKEY_CLASSES_ROOT\AudioCD\shell\play
    (Default)    "&Play"

HKEY_CLASSES_ROOT\AudioCD\shell\play\command
    (Default)    "%SystemRoot%\cdplayer.exe /play %1"

HKEY_CLASSES_ROOT\DVD\shell
    (Default)    "Play"

HKEY_CLASSES_ROOT\DVD\shell\play
    (Default)    "&Play"

HKEY_CLASSES_ROOT\DVD\shell\play\command
    (Default)    "%SystemRoot%\system32\dvdplay.exe /play %1"

From detection to application[edit]

The illustration shows how AutoPlay proceeds to the execution of an application in response to the detection of hardware or media by the Shell Hardware Detection service.[3][7]

#Volumes #AutoRun #Content sniffing #PerceivedType #Content types #EventHandler (volume) #Handler table lookup #Dialogs and decisions HKLM\...\AutoPlayHandlers\Handlers\''handler'' HKLM\...\AutoPlayHandlers\EventHandlers\ShowPicturesOnArrival #Non-volumes #Device characteristics #Device Handler #Events and Handlers #EventHandler (non-volume) #Handler table lookup #Dialogs and decisions HKLM\...\AutoPlayHandlers\Handlers\''handler'' HKLM\...\AutoPlayHandlers\DeviceClasses\{CC7BFB41-F175-11D1-A392-00E0291F3959} HKLM\...\AutoPlayHandlers\DeviceHandlers\VideoCameraDeviceHandler\EventHandlers\DeviceArrival HKLM\...\AutoPlayHandlers\EventHandlers\VideoCameraArrival
AutoPlay process flow. This image has an associated image map.

The process flow is examined by initially dividing it into two groups by device type. The division lasts until the "Handler Table(s) Lookup" stage, when the AutoPlay process becomes much the same for both types of devices. Each part of the process, along with any relevant Registry entries, is described in subsequent sections.

The AutoPlayHandlers key[edit]

AutoPlay relies on the Windows Registry to store all its settings. All machine-wide AutoPlay settings are rooted on the following key:

HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers

As this is a rather unwieldy key to refer to, this article will use an abbreviated version:

HKLM\...\AutoPlayHandlers

Device types[edit]

There are two basic categories of devices as viewed by Windows and by AutoPlay. The volume based devices are those for which the GetDriveType Windows API call returns one of:

Type name Description
DRIVE_REMOVABLE The drive is removable (floppy drive, USB and FireWire drives)
DRIVE_FIXED The disk cannot be removed from the drive (hard disk)
DRIVE_REMOTE The drive is a remote (network) drive
DRIVE_CDROM The drive is a CD-ROM or DVD-ROM drive
DRIVE_RAMDISK The drive is a RAM disk

All volume based devices show up under My Computer with a drive letter. They present Windows with a file system which is accessible using Explorer and which AutoPlay can examine (or sniff) to see what types of files they contain. Many volume based devices need a medium (a CD, disk or card) inserted and mounted to show as an accessible volume in My Computer. For AutoPlay to function, the device must have AutoRun-compatible drivers which will notify the system that a disk has been inserted. Some devices, like floppy drives cannot notify the system when a disk is inserted and will not produce an AutoPlay dialog.

The non-volume based devices are those which are not volumes, i.e. everything else. Digital cameras, video cameras, certain portable music players and anything which does not show up under My Computer is a non-volume device. However, the more modern the camera or music player is, the more likely it is to present Windows with a viewable file system. These types of cameras and players would thus be considered volume devices.

Events and Handlers[edit]

The discovery of a new medium or device by the Shell Hardware Detection service is termed an Event. There are four different types of Events: the Arrival and Removal of "Devices" and the Arrival and Removal of "Media". These Event types are labelled appropriately: DeviceArrival, DeviceRemoval, MediaArrival and MediaRemoval.

Although it would seem appropriate that the arrival of a volume would be a MediaArrival and the arrival of a non-volume a DeviceArrival, none of these Event types are used for volumes at all (See EventHander (volume)).

Handlers, as discussed previously, are the actions presented to the user when AutoPlay is invoked. A Handler is a grouping of the information describing how an application is to be called along with textual information, normally localised to the user's preferred language, which is used to represent the action in the AutoPlay dialog. Multiple Handlers can use a single application, calling it in different ways or with different options. The information stored in a Handler is described in more detail in the Handlers section.

Volumes[edit]

AutoRun[edit]

If a file called autorun.inf exists in the root directory of the file system, settings in that file can add to the options presented to the user or affect the view AutoPlay has of the content. Under Windows XP, the existence of this file may affect the process flow – AutoRun can proceed to executing an application directly without user intervention. Under Windows Vista, AutoRun cannot bypass AutoPlay in this way; it can only add to the options presented to the user. The Inf handling section of the AutoRun article details when and whether AutoPlay is invoked.

The AutoRun layer initially consults Windows Registry values to decides whether to initiate actions for any particular drive or drive type. If AutoRun has been disabled for the newly discovered volume, then the process halts at that point, effectively disabling AutoPlay for that volume.

Content sniffing[edit]

After AutoRun completes, AutoPlay initiates by doing an examination of the volume for content. This is called content sniffing. AutoPlay decides whether the volume is an Audio CD, movie DVD, a blank recordable medium (a CD-R, CD-RW, DVD+R etc.) or a generic volume which contains files.

In the case of a generic volume, AutoPlay starts with the root directory and searches the file system to a depth of four directory levels below the root directory to find file types that fall into certain categories or "content types".

If this search takes more than a second or so, a progress dialog shows the scanning process taking place. This dialog can easily be confused with an Explorer copy operation; however, no files are being copied or moved.

Content types[edit]

As far as AutoPlay sniffing is concerned, files fall into three main categories or "content types". Files outside these categories are not of interest:

Pictures   .jpg .gif .bmp .png ...
Music   .mp3 .wav .wma ...
Video   .avi .mpg ...

Content is considered to be "Mixed content" if files fall into more than one of the three categories.

Content is considered to be Unknown if the content sniffing process finds no categorisable content. This does not mean that there are no files present, just no files falling into one or more of the above three content types. In this case AutoPlay opens an Explorer window on the root directory of the medium and the process flow finishes here.

PerceivedType[edit]

In order to class files into the three content types, the PerceivedType value associated with various file extensions is used to make the category determination. PerceivedType can be set to "image", "audio" or "video" to class files into Pictures, Music or Video content types respectively. There are other PerceivedTypes known to Windows (text, compressed, system and application) but these are not relevant to AutoPlay.

All file type information is stored in the Registry under HKEY_CLASSES_ROOT. The following is the PerceivedType Registry information for .avi Video files and .mp3 Music files:

HKEY_CLASSES_ROOT\.avi
    (Default)        "avifile"
    PerceivedType    "video"

HKEY_CLASSES_ROOT\.mp3
    (Default)        "mp3file"
    PerceivedType    "audio"

EventHandler (volume)[edit]

The EventHandler is the title of a table that makes an association between various Handlers and the triggering Event. In the case of volume-based events, the EventHandlers are generated completely internally to AutoPlay with no reference to the Registry.

Note that examination of the AutoPlayHandlers section of the Windows Registry reveals the ContentTypeSniffers and ContentTypeHandlers keys. Off these keys, various subkeys and values would appear to relate to and even control volume-based AutoPlay. However, as of Windows XP SP2, these keys are defined solely for future use and are not accessed by AutoPlay.[8]

One of the following predefined EventHandlers are chosen based solely on the decision AutoPlay makes internally after volume examination and content sniffing:

Media or content type EventHandler
Pictures ShowPicturesOnArrival
Music files PlayMusicFilesOnArrival
Video files PlayVideoFilesOnArrival
Mixed content MixedContentOnArrival
Blank CD-R/CD-RW HandleCDBurningOnArrival
Music CD PlayCDAudioOnArrival
DVD movie PlayDVDMovieOnArrival
Added in Windows Vista
Super VideoCD movies PlaySuperVideoCDMovieOnArrival
VideoCD movies PlayVideoCDMovieOnArrival
An autorun.inf specifies an executable AutorunINFLegacyArrival[9]

Non-volumes[edit]

Device characteristics[edit]

As Windows cannot perform content sniffing on non-volume devices, AutoPlay analyses these devices by their characteristics rather than by their content. Every newly discovered device has identification information, normally stored within the device itself. This information is gather by enumerators and is used to build identification strings which Windows refers to when accessing and referring to the device. An identification string for a particular device is called a Device ID.[10]

In order to uniquely identify each instance of each device that is installed, Windows assigns an Instance ID to each device. This ID contains location information, or a serial number if supported.

Combining the Device ID with the Instance ID gives a string which uniquely identifies an individual device in a system. This is the Device Instance ID. An example of a string from a PCI device is:

PCI\VEN_1274&DEV_1371&SUBSYS_8030107B&REV_04\0&0E

When Windows discovers a new device, it stores the Device Instances in the Registry from:

HKLM\SYSTEM\CurrentControlSet\Enum

The Windows Device Manager (Located under the System icon in the Control Panel) will reveal the Device Instance ID for any particular device. Getting the Properties of any device, selecting the Details tab of the Properties dialog and selecting "Device Instance ID" from the drop down box will retrieve the information.

Another characteristic of every device is the Device Interface Class.[11] This defines an interface contract, where a device agrees to support a basic set of Input/Output Control calls pertaining to that Device Interface Class. For example, a device agreeing to support the keyboard interface contract must support the IOCTL_KEYBOARD_QUERY_ATTRIBUTES IOCTL call, amongst others. Each class is represented as a large universally unique number called a GUID.

A device can register many Device Interface Class GUIDs for itself, contracting to support various appropriate interface calls. The most common Interface Class GUID relating to storage devices is the Volume Device Interface Class GUID, {53F5630D-B6BF-11D0-94F2-00A0C91EFB8B}.

Device Interface Class GUIDs can be found in the Registry under:

HKLM\SYSTEM\CurrentControlSet\Control\DeviceClasses.

Device Handler[edit]

When a non-volume device is being analysed, AutoPlay looks in several places in the Registry for a DeviceHandlers entry. This is simply a string which, when combined with other information, selects an EventHandler (which tables the Handlers). The DeviceHandlers entries are commonly placed into the Registry by the manufacturer of the device. There are also broader categories of devices which have preassigned DeviceHandlers, Video Camera devices for example.

The first place AutoPlay looks is under the Device Parameters key of the device instance. For example:

USB\Vid_059b&Pid_0031&REV_0100

is the USB device identification string for an Iomega USB ZIP drive. Combined with a USB serial number, say 059B003112010E93, this forms the Device Instance ID for the device. Thus the Device Parameters key is found at:

HKLM\...\Enum\USB\Vid_059b&Pid_0031\059B003112010E93\Device Parameters
    Icons             ""
    NoMediaIcons      ""
    Label             ""
    DeviceHandlers    "ZipDeviceHandler"

The DeviceHandlers value in this case is "ZipDeviceHandler". Other device parameters may also be present here: Icons may specify an icon to represent the device along with NoMediaIcons to represent the device when it has no media present. Label specifies a friendly name for the device.

If no DeviceHandlers entry is found under the device instance, AutoPlay checks for the existence of a DeviceGroup entry, again under the device instance. This allows a whole set of devices to share device parameters.

HKLM\...\Enum\USB\Vid_059b&Pid_0031\059B003112010E93\Device Parameters
    DeviceGroup    "ZipDrive100"

The parameters for this device group are stored in:

HKLM\...\AutoPlayHandlers\DeviceGroups\devicegroup

So for the ZipDrive100 group example:

HKLM\...\AutoPlayHandlers\DeviceGroups\ZipDrive100
    Icons             "%SystemRoot%\system32\shell32.dll,-230\0\0"
    Label             "Zip Drive 100"
    DeviceHandlers    "ZipDeviceHandler"

Lastly, AutoPlay searches the relevant Device Interface Class GUIDs. The parameters for device classes are stored in:

HKLM\...\AutoPlayHandlers\DeviceClasses\{classguid}

Here is the entry that the Microsoft application Movie Maker registers for any and all Video Camera devices:

HKLM\...\AutoPlayHandlers\DeviceClasses\{CC7BFB41-F175-11D1-A392-00E0291F3959}
    DeviceHandlers    "VideoCameraDeviceHandler"
    Label             "@C:\Program Files\Movie Maker\wmm2res.dll,-63094"
    Icons             "C:\WINDOWS\system32\shell32.dll,-317\0\0"

EventHandler (non-volume)[edit]

Once a Device Handler is selected, it is combined with the triggering Event to produce a Registry key relative to the AutoPlayHandlers key:

HKLM\...\AutoPlayHandlers\DeviceHandlers\devicehandler\EventHandlers\event

For example, on the arrival of a Video Camera, the Device Handler is "VideoCameraDeviceHandler" and the event is "DeviceArrival". The key looked up is:

HKLM\...\AutoPlayHandlers\DeviceHandlers\VideoCameraDeviceHandler\EventHandlers\DeviceArrival
    VideoCameraArrival    ""

The result is the EventHandler name which in this case is "VideoCameraArrival". The entry data is empty.

Building the AutoPlay dialog[edit]

Handler table lookup[edit]

Once an EventHandler name is chosen, the corresponding table is used to build a list of Handlers. Each table is stored at

HKLM\...\AutoPlayHandlers\EventHandlers\eventhandler

and consists of a list of entries. The entry name is the name of the Handler and the entry data is blank.

For example, if the result of the AutoPlay volume analysis is the ShowPicturesOnArrival EventHandler, the corresponding table could look like this:

HKLM\...\AutoPlayHandlers\EventHandlers\ShowPicturesOnArrival
    MSWiaEventHandler
    MSShowPicturesOnArrival
    MSPrintPicturesOnArrival
    MSOpenFolder

This would result in four Handlers being chosen to represent the Event in the AutoPlay dialog. In the above example, the Handler names listed do correspond to the choices given for the "Pictures" section shown in the table of default settings.

Handlers[edit]

The information for each Handler is stored at:

HKLM\...\AutoPlayHandlers\Handlers\handler

and consists of a set of entries which determine the application to be called and the descriptions of the action in the AutoPlay dialog. The Handler information differs depending on whether or not the system can read the device contents directly. By including the appropriate information, a single Handler can support both volume and non-volume events. MSWiaEventHandler (The Camera and Scanner Wizard) is an example of this type of Handler.

Given the volume Handler MSShowPicturesOnArrival, the information entries could look something like:

HKLM\...\AutoPlayHandlers\Handlers\MSShowPicturesOnArrival
    DefaultIcon     "%SystemRoot%\system32\SHELL32.dll,-249"
    Action          "@%SystemRoot%\system32\SHELL32.dll,-17156"
    Provider        "@%SystemRoot%\system32\SHELL32.dll,-17157"
    InvokeProgID    "Shell.AutoplayForSlideShow.1"
    InvokeVerb      "open"

The DefaultIcon, Action and Provider entries are used in the AutoPlay dialog as follows:

AutoPlay Handler info.png

The Action and Provider values can be literal strings or references to resource strings. Resource strings have the distinct advantage of having a language associated with them. In an English locale, the Action resource reference in the example above might equate to "View a slideshow of the images", but in another locale the string could automatically display in the appropriate language.

The DefaultIcon value can either be the name of a .ico file or an icon resource. Icon resources are referenced in a similar manner to string resources except that @ symbol is not used. Icons can be stored in a binary file in two ways: If the number after the file name is less than zero then the number is the resource ID; otherwise the number is the index of the icon. It is recommended to use the negative numbered resource IDs.

The InvokeProgID and InvokeVerb values are used to start the application via the ShellExecuteEx API call. This is the same method used to, say, start Notepad when a user double-clicks on a .txt file; the application is not started directly. The values are Registry keys under HKEY_CLASSES_ROOT. In the example above, the relevant key would be:

HKEY_CLASSES_ROOT\Shell. AutoplayForSlideShow.1

Non-volume Handlers are stored alongside the volume Handlers but they look slightly different. Given that the data on the device is only accessible through an interface and not directly readable using a file system, the Handler information entries deal primarily with starting the application (if not already running) via the Windows Component Object Model (COM) infrastructure. AutoPlay then uses the COM links thus established to feed information about the event that occurred and the device that caused it.

Here is the Registry information for the non-volume Handler, MSVideoCameraArrival:

HKLM\...\AutoPlayHandlers\Handlers\MSVideoCameraArrival
    DefaultIcon       "C:\Program Files\Movie Maker\moviemk.exe,0"
    Action            "@C:\Program Files\Movie Maker\wmm2res.dll,-63095"
    Provider          "@C:\Program Files\Movie Maker\wmm2res.dll,-100"
    InitCmdLine       ""C:\Program Files\Movie Maker\moviemk.exe" /RECORD"
    ProgID            "Shell.HWEventHandlerShellExecute"
    CLSIDForCancel    "{AB007EC8-E2D4-4664-ACD9-1D059681F3DE}"

The DefaultIcon, Action and Provider entries are the same as before, however InitCmdLine and ProgID are used instead of InvokeProgID and InvokeVerb. The CLSIDForCancel entry shown above is for information purposes only. A CLSID entry can be used instead of ProgID, the latter being preferred. ProgID refers to the HKEY_CLASSES_ROOT entry where the appropriate COM CLSID can be found.

The ProgID value points to a COM component implementing the IHWEventHandler interface and the InitCmdLine value is used with the IHWEventHandler::Initialize method. Technical details are available from the articles referred to in the External Links section below.

Available Handlers[edit]

On a default installation of Windows, there are a pre-existing set of Handlers available. This is a list of the default Handlers present on an installation of Windows XP SP2. Handlers may change name over time or be merged – MSPlayMusicFilesOnArrival and MSPlayVideoFilesOnArrival were merged into MSPlayMediaOnArrival when Windows Media Player took over the handling of music and video file content types.

Volume (files) Non-volume (interface)

MSOpenFolder

MSCDBurningOnArrival
MSWMPBurnCDOnArrival

MSPlayMediaOnArrival
MSShowPicturesOnArrival
MSPrintPicturesOnArrival

MSPlayCDAudioOnArrival
MSRipCDAudioOnArrival
MSPlayDVDMovieOnArrival

MSPlayVideoCDMovieOnArrival
MSPlaySuperVideoCDMovieOnArrival

MSWiaEventHandler

MSTakeNoAction
MSPromptEachTime
MSPromptEachTimeNoContent

MSVideoCameraArrival
MSSHAudioDevHandler

MSWMDMHandler
MSWPDShellNamespaceHandler

MSWiaEventHandler

Note that MSWiaEventHandler (The Camera and Scanner Wizard) can handle both volume and non-volume devices, MSPlayMediaOnArrival handles both music and video and MSWMDMHandler is the "Windows Media Device Manager" which handles certain types of non-volume music players.

Dialogs and decisions[edit]

Once the list of Handlers is chosen the DefaultIcon, Action and Provider entries from each Handler are used to build the icons and strings that display the choices in the AutoPlay dialog. A particular item in the dialog may be selected as the default (highlighted) choice. This default can be modified using Registry settings. The dialog may not always be shown; a choice may be made automatically depending on user preferences.

User preferences are stored in an AutoPlayHandlers section under HKEY_CURRENT_USER:

HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers

Setting a user's default highlighted preferences is achieved by adding entries to:

HKCU\...\AutoPlayHandlers\EventHandlersDefaultSelection

in the form: eventhandler = "handler". For example,

ShowPicturesOnArrival = "MSOpenFolder"

will make that Handler the default for the ShowPicturesOnArrival EventHandler table.

Automatic AutoPlay selections is set through the AutoPlay tabs on the relevant properties dialogs. The settings are stored under HKEY_CURRENT_USER but have changed position in various versions of Windows. The setting is stored as an entry name which is a combination of information from the MountedDevices section of the Registry (HKLM\SYSTEM\MountedDevices) plus the EventHandler name, and entry data which is the Handler name. It is possible to manually trace the strings used by parsing MountedDevices manually or tracing back from the ParentIdPrefix settings under the enumeration tree, however this is undocumented and unlikely to be portable between Windows versions.

However, to illustrate the setting, this is the data that is used when AutoPlay is configured for a flash drive (note that the entry name is wrapped due to length):

HKCU\...\AutoPlayHandlers\UserChosenExecuteHandlers
    H:\\?\STORAGE#RemovableMedia#7&34ec5d6b&0&RM#{53f5630d-b6bf-
      11d0-94f2-00a0c91efb8b}+PlayMusicFilesOnArrival = "MSPlayMediaOnArrival"

Altering AutoPlay[edit]

Disabling AutoPlay[edit]

In Windows 7 disabling AutoPlay for specific Media types and devices, can be done through clicking on "AutoPlay" under the "Hardware and Sound" category in the Control Panel.[12]

Prior to Windows 7, disabling AutoPlay from triggering at all for any non-volume device is not possible without an application intervening to cancel the triggering event (see Cancellation below).

An alternative method is changing AutoRun specific Registry settings (see AutoRun above) or from Windows 7, there is a "Turn off Autoplay for non-volume devices" Group Policy available.

Cancellation[edit]

Volume cancellation can be done through an application by listening to the QueryCancelAutoplay Windows message, or by implementing the IQueryCancelAutoplay COM interface.

Non-volume cancellation is achieved by implementing the IHWEventHandler COM interface.

Further specifics are available from the November 2001 MSDN Magazine article on AutoPlay[3] along with code examples from the AutoPlay Demo CodeProject.com article.[13]

Other settings[edit]

From Windows Vista and Windows Server 2008, the "Don't set the always do this checkbox" Group Policy is available. If this policy is Enabled, the "Always do this..." checkbox in the AutoPlay dialog will not be set by default when the dialog is shown.

From Windows Vista, at the Dialogs and decisions point of the AutoPlay execution sequence, there is a check to see if the Shift key is currently being held down. If so, any automatic user preferences are ignored and the AutoPlay dialog is always shown.

See also[edit]

Software providing similar functionality in other environments

References[edit]

External links[edit]