Using the Windows Portable Devices (WDP) API for fun and... fun...
- Posted: Apr 23, 2012 at 6:00 AM
- 9,019 Views
- 3 Comments
Loading User Information from Channel 9
Something went wrong getting user information from Channel 9
Loading User Information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Today's Mobile Monday post is going to be different than most... Instead of Windows Phone 7, etc, we're going to focus on a series of posts that covers an API that many may not know about, but once you do, might get you thinking about the cool stuff you can do with it (I know I am...)
What is this API? The Windows Portable Devices (WDP) API. This is a COM API that is not the most .Net friendly, yet Christophe Geer has a working series of posts that walks you through using it in .Net, from enumeration the content, to grabbing content off, deleting stuff and in the latest post, transfer content from your computer to the device.
What kinds of devices? He shows off examples with cameras and Kindles. So imaging writing some kind of cool utility that explorers, lists, transfers stuff to and from your Kindle. Or building that kind of thing into one of your own app's...
Let's focus on the latest post;
Mayhap came here sooner than I thought. The previous article on the WPD API dealt with deleting resources. Too destructive perhaps, let’s create some resources this time.
My Kindle’s is hooked up to my PC. Let’s see if I can transfer a book to it.
Table Of Contents
In the Solution Explorer select the Program.cs file and open it. Clear the Main(…) method and add the following code to it.var devices = new PortableDeviceCollection();
var kindle = devices.First();
First we establish a connection to the Kindle, copy the book to it and finally disconnect from it
The magic happens in the TransferContentToDevice(…) method, which takes two parameters:
- fileName: Full path of the file which you want to copy to the device
- parentObjectId: The ID of the parent folder into which you want to copy the file
Modify the values of these parameters to suit your situation.
Before we can start to implement the TransferContentToDevice(…) method we first need to add another private method to the PortableDevice class type.
The post continues into much more depth and details and provides from good geek reading. The other posts in this series are the same, providing simple examples up front and then going into a very nice level of details.
If you've always wanted to build a utility for that portable device, camera, Zune (yes, Zune, I was able to at least get a very raw listing of my Zune HD's content) or Kindle, this is a series of posts you should check out.