Basic Set of Properties for Folder Creation

When creating a folder object, the following properties are required when calling IPortableDeviceContent::CreateObjectWithPropertiesOnly:

  • WPD_OBJECT_PARENT_ID:  VT_LPWSTR, Parent Object ID
  • WPD_OBJECT_NAME: VT_LPWSTR, Name of the new object
  • WPD_OBJECT_CONTENT_TYPE = WPD_CONTENT_TYPE_FOLDER
  • WPD_OBJECT_FORMAT = WPD_OBJECT_FORMAT_PROPERTIES_ONLY

Some devices (such as the Toshiba MES30VW Gigabeat) require the following additional property when creating a folder object, or the object creation would fail with 0x80040000.  

  • WPD_OBJECT_ORIGINAL_FILE_NAME: VT_LPWSTR, Original file name of the new object

Typically, the original file name property can be set to the same value for WPD_OBJECT_NAME.

Basic Set of Properties for Creating Other Objects

For creating other objects, the set of required properties will vary depending on the Content Type of the object.   For creating objects with data (such as a Music or an Image file), use IPortableDeviceContent::CreateObjectsWithPropertiesAndData.    

 

Debugging Object Creation Failures (and Others)

You can run WpdMon to view the traffic between the application and the responses from the device.   This helps to zero in on the errors and responses from the driver before the error codes are bubbled up to the application level. 

The following capture shows an attempted folder creation on an MTP device (the Creative Zen Vision M) using the WPD Shell Namespace Extension (i.e. Explorer).   IPortableDeviceContent::CreateObjectWithPropertiesOnly corresponds to the WPD driver command WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY.  

Date Created and Date Modified are both additional optional properties that the WPD Shell Namespace chooses to specify when creating folder objects.  

The client information context is a string identifier that is added automatically by the WPD API in the command parameters.   This is generated internally by the WPD API during IPortableDevice::Open, and uniquely identifies the IPortableDevice instance.

 

Timestamp: 03/02/2007 10:48:25.0806
Operation: (Request) WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY from Application (4 elements)
WPD_PROPERTY_COMMON_COMMAND_CATEGORY                         = [VT_CLSID   ] WPD_CATEGORY_OBJECT_MANAGEMENT
WPD_PROPERTY_COMMON_COMMAND_ID                               = [VT_UI4     ] 0x2 (Decimal: 2) WPD_PROPERTY_OBJECT_MANAGEMENT_CREATION_PROPERTIES = [VT_UNKNOWN ] IPortableDeviceValues (7 elements)
WPD_OBJECT_PARENT_ID                                         = [VT_LPWSTR  ] s10001
WPD_OBJECT_ORIGINAL_FILE_NAME                                = [VT_LPWSTR  ] New Folder
WPD_OBJECT_NAME                                              = [VT_LPWSTR  ] New Folder
WPD_OBJECT_DATE_CREATED                                      = [VT_DATE    ] 2007/3/2 10:48:25.0
WPD_OBJECT_DATE_MODIFIED                                     = [VT_DATE    ] 2007/3/2 10:48:25.0
WPD_OBJECT_CONTENT_TYPE                                      = [VT_CLSID   ] WPD_CONTENT_TYPE_FOLDER
WPD_OBJECT_FORMAT                                            = [VT_CLSID   ] WPD_OBJECT_FORMAT_PROPERTIES_ONLY
WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT               = [VT_LPWSTR  ] {F86BC3B3-D205-463F-80CF-DB43C51D4FE2}

Timestamp: 03/02/2007 10:48:25.0806
Operation: (Response) IPortableDeviceValues from Driver (1 elements)
WPD_PROPERTY_COMMON_HRESULT                                  = [VT_ERROR   ] 0x800700AA

 

Even though the application has provided all the required property values (and then some), the WPD driver still failed the command with 0x800700AA (ERROR_BUSY).  This means that the driver is busy servicing other requests, and the application should try the request again later.    By using WpdMon, we are able to determine that the failure in CreateObjectWithPropertiesOnly had originated from the driver or the device.

This post provides more details on ERROR_BUSY.

The same technique of viewing WpdMon traffic can be applied to diagnosing error responses returned from other methods in the WPD API to determine which level the error appeared (the application, the WPD API, or the driver/device).   The trick is to map the WPD API call to the driver command.   It is a straightforward mapping, for example:

IPortableDeviceProperties::GetValues => WPD_COMMAND_OBJECT_PROPERTIES_GET

More tips and tricks for using WpdMon.

 

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