he primary purpose of Autoplay is to provide a software response to hardware actions initiated by the user on the machine. The Autoplay feature remained roughly the same from Windows® 95 though Windows 2000 and Windows Millennium Edition (Me) because up until recently there have been very few new scenarios with regard to user-initiated hardware events that could trigger a useful Autoplay action. But lately, with the spread of digital multimedia content (music, graphics, and video) and of the many devices to generate or consume that content, many new scenarios are begging for Autoplay to grow. Windows XP reflects the rapid growth of consumer multimedia with an expanded Autoplay feature. In addition to refining the existing Autorun.INF mechanism, audio CD Autoplays, and DVD video Autoplay, support has been added to handle digital music (WMA/MP3), graphics, video, CD burning, video cameras, and other hardware devices. In this article, the pre-Windows XP Autoplay will be referred to as Autoplay V1. Autoplay V2 refers to the new Autoplay features introduced in Windows XP. In this article we'll cover Autoplay features for both versions. The new features will be illustrated through the sample code available for download with this article. Sample 1 demonstrates a typical application registering to handle volume Autoplay events and enumerating the detected files provided through the IDropTarget interface. Sample 2 demonstrates an application that registers to handle video camera arrival events and also shows how to cancel these Autoplay events. The application could easily be modified to handle other non-volume Autoplay events and cancellation. Sample 3 demonstrates how to cancel all possible volume Autoplay events using the two cancellation mechanisms.
If you've installed software from a CD, you've used Autorun.INF. A majority of the setup CDs targeted at the Windows platform use it. The typical user scenario is this: a CD is inserted into the CD drive, the setup program runs automatically, and the user simply follows the on-screen instructions generated by the setup software. Without this mechanism, the user needs to find and open the My Computer folder, find the CD drive, double-click the icon, find the right program to run, and launch it. For novice users, all of these steps are far from obvious and can contribute to the perceived complexity of the PC. Autoplay functionality relies on the presence of a file named Autorun.INF located in the root of the volume. The file follows the typical format of Windows INI files and must have an [autorun] section. A simple autorun section might look like this:
interface IQueryCancelAutoPlay : IUnknown
HRESULT AllowAutoPlay([in, string]LPCWSTR pszPath,
[in, string]LPCWSTR pszLabel,
[in] DWORD dwSerialNumber);
LogFile [REG_DWORD] = 1
More MSDN Magazine Blog entries >
Browse All MSDN Magazines
Subscribe to MSDN Flash newsletter
Receive the MSDN Flash e-mail newsletter every other week, with news and information personalized to your interests and areas of focus.