Freigeben über


Enabling Your WPD application for AutoPlay on Windows Vista

The power of WPD derives from built-in extensibility mechanisms and scenarios around content type and device function.  A good example is AutoPlay, which has been updated in Windows Vista to support WPD scenarios.   Instead of providing the ability to only register for devices as a whole, AutoPlay now allows a generic scheme where each WPD device provides a list of content and functional categories that it supports.   Application handlers can register for each type of content and function category that they are interested in.  

Overview of the WPD AutoPlay Registration Scheme

The WPD AutoPlay scheme is defined as follows:

Source

  • The list of content types in this group indicates what the device can provide.
  • This allows for applications that are interested in browsing or acquiring device contents to be registered for devices that can provide that content.

Sink

  • The list of content types in this group indicates what the device can accept.
  • This allows for applications that are interested in putting content on the device to be registered for devices that can receive that content. 

Function

  • The list of categories in this group indicates what functions the device supports.
  • This allows for applications that are interested in device functionality (e.g. ability to send/receive SMS messages) to be registered for devices that can provide that function.

Note that this scheme is not limited to the content the device currently has on its storage, but rather, what the device is capable of storing/doing

When a device arrival event occurs, AutoPlay will walk the list of capabilities reported by the WPD driver (e.g. "Source for Audio"), and for each type found on the list, AutoPlay will walk the list of registered handlers to find a match.    The lists of handlers for the supported types are merged into a single list of handlers and presented to the user in the AutoPlay Dialog.

Registering Your WPD Application for AutoPlay

To register for WPD AutoPlay events, applications need to add themselves to the appropriate WPD entry under the AutoPlayHandlers\EventHandlers key.  To illustrate a simple application registration, suppose your WPD application can transfer Music to a WPD device, and can receive Music and Photos from a WPD device.   You could register your application handler like this:

[HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers\EventHandlers\Wpd]:

Sink
    {4AD2C85E-5E2D-45E5-8864-4F229E3C6CF0} -> WPD_CONTENT_TYPE_AUDIO
                         MyWpdSendMusicHandler, REG_SZ, (Empty)

Source
    {4AD2C85E-5E2D-45E5-8864-4F229E3C6CF0} -> WPD_CONTENT_TYPE_AUDIO
                         MyWpdAcquirePhotoMusicHandler, REG_SZ, (Empty)

    {EF2107D5-A52A-4243-A26B-62D4176D7603} -> WPD_CONTENT_TYPE_IMAGE
                         MyWpdAcquirePhotoMusicHandler, REG_SZ, (Empty)

Both [MyWpdAcquirePhotoMusicHandler] and [MyWpdSendMusicHandler] are normal Autoplay registrations in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers.   For more details, refer to this MSDN article (suggested section: Autoplay V2 Registration Mechanism).

The "EventHandlers\Wpd\..." entries are defined using the content type and functional category GUIDs (e.g. {EF2107D5-A52A-4243-A26B-62D4176D7603}), not the symbolic names (i.e. WPD_CONTENT_TYPE_IMAGE).   This is designed to support extensibility for custom content types and functional categories that devices and applications can register.  Published WPD GUID values and their associated symbolic names are defined in PortableDevice.h, available in the Windows SDK.

"Source" and "Sink" are content transfers relative to the device, not the application.    In the example above, your application is registering for AutoPlay events for a WPD device that can do one or more of the following:

  1. Receive music content from your application
  2. Provide image or audio content to your application 

If your application is a general purpose WPD application that wants to register for any device, you can add a handler entry under the WPD_CONTENT_TYPE_ALL, e.g. in ...\Wpd\Source\{80E170D2-1055-4A3E-B952-82CC4F8A8689}.   Note that this will also register your application to handle devices that support custom content types.
 

AutoPlay for Functional Category 

Function registration provides a great way for your WPD application to register to handle devices that support specific commands or scenarios that are organized by functional category. 

For example, if your application interfaces with cameras that support image capture, register your handler for WPD_FUNCTIONAL_CATEGORY_STILL_IMAGE_CAPTURE, so that when a device that supports this functional category is connected, your app can be present in the AutoPlay dialog:

[HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers\EventHandlers\Wpd]: 

Function
    {613CA327-AB93-4900-B4FA-895BB5874B79}  -> WPD_FUNCTIONAL_CATEGORY_STILL_IMAGE_CAPTURE
                          MyWpdImageCaptureHandler, REG_SZ, (Empty)  

Can I register AutoPlay for other device events?

AutoPlay only supports registration for device arrival events.   Your application can still receive WPD events and custom events using IPortableDevice::Advise.

What about Windows XP?

The granular WPD Source/Sink/Function AutoPlay registration functionality is only available on Windows Vista.   On Windows XP, the AutoPlay registration mechanisms are documented in this MSDN article and in the MSDN library.

 

This posting is provided "AS IS" with no warranties, and confers no rights.

Comments