Browse by Tags

Tagged Content List
  • Blog Post: Where is wpdmtpextensions.h?

    The header file - Wpdmtpextensions.h - has been referenced in several of my posts and is needed to talk MTP to the device through WPD. The header file is not available in the Vista SDK/WDK or the WMP 11 SDK, but is planned for inclusion in the Windows Server code name "Longhorn" SDK. I've just received...
  • Blog Post: Creating a WPD playlist object in C#

    This is a C# follow-up post on the earlier C++ playlist creation post . Be sure to read the earlier post for background information on playlists and how it stores references. We will also re-use the StringToPropVariant helper function that we defined in our previous post . To create a playlist object...
  • Blog Post: Creating WPD PROPVARIANTs in C# without using interop

    Previous posts have covered how to create, manage and marshal PROPVARIANTs using interop. Here's a way on how to create a PROPVARIANT without interop. The IPortableDeviceValues interface exposes a SetStringValue method that allows a regular C# string to be added into the collection. IPortableDeviceValues...
  • Blog Post: Marshalling variant properties in C#

    This post is a continuation of the one covering WPD property retrieval in C# . That post explained how to marshal strings and the basic int properties. Handling other types such as VT_DATE and VT_BOOL is trickier so I'll try to cover them here. VT_DATE VT_DATE variants hold the date time value in a field...
  • Blog Post: WPD Content Enumeration in C#

    WPD content enumeration in C# is pretty close to the C++ style. Here's a basic example that enumerates the object IDs of the objects present on the device. static void Enumerate( ref PortableDeviceApiLib.IPortableDeviceContent pContent, string parentID, string indent) { // // Output object...
  • Blog Post: Setting WPD properties in C#

    Since setting a WPD property requires manipulating a PROPVARIANT structure through interop, we must make use of the marshalling rules we set in our last post . We'll take a look at a function that allows string properties to be set. static void SetStringValue( PortableDeviceApiLib.PortableDeviceClass...
  • Blog Post: WPD property retrieval in C#

    WPD property values are retrieved as PROPVARIANTs through the WPD API. Unfortunately there is no native support for PROPVARIANTs in C#. To correctly retrieve the property values (or anything that is in a PROPVARIANT) through the WPD API in C#, we must use marshalling. PortableDeviceApiLib.tag_inner_PROPVARIANT...
  • Blog Post: Where are the WPD property keys in C#?

    If you followed the exercise from our first C# post , you must have noticed that the PortableDeviceApi and PortableDeviceTypes typelibs don't expose the WPD property keys such as WPD_OBJECT_ID, WPD_OBJECT_FORMAT, etc. This can be a major blocker since for starters, we need to specify a basic set of client...
  • Blog Post: C# and the WPD API

    There currently is no managed/C# flavor of the WPD API. This, of course, doesn't mean that you are locked out from using the WPD API if you want to use C#. Since the API is a set of COM interfaces, we simply have to interop across from C#. Granted it isn't as easy as a native C# implementation, but it...
  • Blog Post: Help! WPD API calls randomly fail with 0x800700AA (ERROR_BUSY)

    If you notice your API calls are randomly failing with HRESULT_FROM_WIN32(ERROR_BUSY) / 0x800700AA / -2147024726, then it's likely that the device driver is indeed busy doing something else. It could be that WMP is syncing content to the device, or maybe Explorer needs to refresh its view and is enumerating...
  • Blog Post: Transferring playlists through WPD

    A playlist (.WPL, .M3U, etc.) is a text file which contains a list of filenames. This list is the "playlist". So transferring the playlist should be easy right? Well, yes it is - if you just want to transfer it as a text file... However if you want the playlist semantics to be sent to the device as...
  • Blog Post: MTP array properties (AINT*/AUINT*) in WPD

    MTP allows for a wide range of array-based data types ranging from an array of bytes (AINT8/AUINT8) to an array of GUIDs (AINT128/AUINT128). Check out section 3.2.1 and 3.2.2 in the MTP specification for a complete list and definition. Unfortunately the WPD API is restricted in the kind of arrays...
  • Blog Post: Accessing MTP vendor extended properties through WPD

    Apart from the standard device and object properties defined in the MTP specification, device vendors are free to add their own properties. The codes for these properties must lie in the vendor-extension range as defined by the MTP spec in section 3.3.1. Specifically, the range for vendor-extended device...
  • Blog Post: Setting WPD properties

    The IPortableDeviceProperties::SetValues API can be used to set WPD object properties. The documentation covers the API parameters as well, so we'll skip to the meatier sample. The SetValues API can be used to set multiple properties at the same time. You can, of course, also just set one property at...
  • Blog Post: How to check if a WPD property can be modified

    We'll create a little helper function that we can use to figure out if a WPD object property can be modified. All WPD object properties have attributes on them. The MSDN documentation provides a complete list of attributes here . We'll take a look at the WPD_PROPERTY_ATTRIBUTE_CAN_WRITE attribute since...
  • Blog Post: Sending MTP commands through WPD (Part 3 - data from device)

    Let's use the GetDevicePropValue command (MTP spec - section D.2.21) to illustrate this. GetDevicePropValue takes one parameter - the device property code that we want to retrieve the current value for. We'll retrieve the BatteryLevel device property (MTP spec - section C.2.2) which is of type UINT8...
  • Blog Post: Sending MTP commands through WPD (Part 2 - data to the device)

    We'll pick the SetDevicePropValue MTP command (MTP spec - section D.2.22) to illustrate this example. This command requires the device property code as a parameter. We'll try setting the DateTime property (MTP spec - section C.2.18). The DateTime property is of type STRING and we've already covered in...
  • Blog Post: Listening to MTP events

    MTP devices can fire events as well. These events are used to educate the PC (or the initiator) about any change in device status. Think of a scenario where you connect a camera extension to an MTP cellphone. The configuration of the cellphone has now changed since it supports camera settings. The device...
  • Blog Post: Listening to WPD Events

    The WPD API allows applications to listen for events from the driver or the device. These events are primarily used to indicate changes in device state such as a new object being added, an object being deleted, etc. A list of possible WPD events is available in the MSDN documentation . The events are...
  • Blog Post: Sending MTP commands through WPD (Part 1 - without a data phase)

    Most WPD API are wrappers around the SendCommand API. The documentation for the SendCommand API provides a pretty good example on how to send commands to a driver. So rather than reinvent the wheel, we'll take a look at how we can use the SendCommand API to send a custom MTP command to an MTP device...
  • Blog Post: Sample code to walk the WPD object hierarchy

    Here's a quick example of a console app that can enumerate the contents of a WPD device. You'll need to link against portabledeviceguids.lib as well. // Disclaimer: The code presented is not endorsed in anyway by Microsoft. Use at your own risk. #include <portabledevice.h> #include <portabledeviceapi...
  • Blog Post: Understanding WPD object hierarchy

    Almost all WPD devices allow content to be stored on them and this suggests that a way of organizing the content would exist. In this post we'll try understanding a typical WPD hierarchy. When a device does allow content to be stored on it, it is through some kind of storage media. In the case of a camera...
  • Blog Post: WPD Collection Interfaces (Part 3)

    We'll cover the last collection type, IPortableDeviceValuesCollection, here. To refresh - Part 1 discussed IPortableDeviceKeyCollection and IPortableDeviceValues while Part 2 covered IPortableDevicePropVariantCollection. IPortableDeviceValuesCollection Going by the name, this collection contains elements...
  • Blog Post: WPD Collection Interfaces (Part 2)

    In the previous part , we took a look at IPortableDeviceKeyCollection and IPortableDeviceValues. In this post, we'll examine the IPortableDevicePropVariantCollection (quite a mouthful :) collection. IPortableDevicePropVariantCollection The documentation for this provides a pretty good idea of what it...
  • Blog Post: WPD video on Channel 9!

    Check out this Channel 9 video on the WPD platform. It's full of demos - check out the one with a WPD driver for a blood glucose meter (22:00 timestamp). There are demos of the WpdInfo and WpdMon tools. WpdInfo and WpdMon are available in the WDK, while WpdMon is also available with the MTP porting kit...
Page 1 of 2 (32 items) 12