<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Windows Portable Devices Team Blog : SDK</title><link>http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx</link><description>Tags: SDK</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Windows 7 Application Samples</title><link>http://blogs.msdn.com/wpdblog/archive/2009/09/25/windows-7-application-samples.aspx</link><pubDate>Sat, 26 Sep 2009 01:52:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9899742</guid><dc:creator>wpdblog</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/9899742.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=9899742</wfw:commentRss><description>
&lt;p&gt;The Windows Portable Devices (WPD) SDK includes two sample command-line applications written in C++. The first application, WpdApiSample, lets the user accomplish tasks like: enumerating connected devices, exploring objects on these devices, and enumerating object properties. The second application, WpdServiceApiSample, is designed to explore a Contacts Device Service. The user can enumerate connected device services, retrieve properties and formats for a given service, and invoke methods on that service. The WPD SDK is included in the Windows SDK which can be downloaded from &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;amp;displaylang=en" mce_href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;amp;displaylang=en&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The following sections describe each sample application, the modules found in that application, and the operating systems that it will run on. &lt;/p&gt;
&lt;h4&gt;WpdApiSample&lt;/h4&gt;
&lt;p&gt;Of the two sample applications, the WpdApiSample, is the most generalized. It demonstrates how a developer would use the WPD API to accomplish tasks common to most applications. For example, this application demonstrates how a developer would:&lt;/p&gt;

&lt;p&gt;· Enumerate the devices connected to a computer.&lt;/p&gt;

&lt;p&gt;· Establish a connection to a connected device.&lt;/p&gt;

&lt;p&gt;· Enumerate device content.&lt;/p&gt;

&lt;p&gt;· Retrieve the properties for a given object on a device.&lt;/p&gt;

&lt;p&gt;· Set the properties for a given object on a device.&lt;/p&gt;

&lt;p&gt;· Retrieve general device information (for example, a description of the operations that a device can perform).&lt;/p&gt;

&lt;p&gt;· Operate on device content (for example, move a file from one folder on the device to another).&lt;/p&gt;

&lt;p&gt;The WpdApiSample application includes the following files: 
&lt;/p&gt;
&lt;table border="1" cellpadding="2" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;&lt;b&gt;File&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ContentEnumeration.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains functions that enumerate all the objects on a device.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ContentProperties.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains functions that read and write object properties and make bulk property set/get requests.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ContentTransfer.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains functions that transfer content to or from the device, read object type requirements, and create a folder on the device.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;DeviceCapabilities.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains functions to list the functional object types on the device, list the content types supported by each functional object type, and display rendering object profiles.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;DeviceEnumeration.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Lists the friendly names, manufacturers, and descriptions of all connected devices.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;DeviceEvents.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains functions that log device events and their parameters whenever events are fired.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;Stdafx.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Includes the standard files.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;WpdApiSample.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Displays a list of available devices and tasks available to the user.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;This application is supported on Windows XP, Windows Vista, and Windows 7. &lt;/p&gt;

&lt;p&gt;Even if you have no WPD devices connected to your computer, you can familiarize yourself with the WPD API and this application by installing the WpdHelloWorldDriver sample from the Windows Driver Kit (WDK), which emulates a simple WPD device. For information about downloading the WDK, see &lt;a href="http://www.microsoft.com/whdc/resources/downloads.mspx" mce_href="http://www.microsoft.com/whdc/resources/downloads.mspx"&gt;http://www.microsoft.com/whdc/resources/downloads.mspx&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;WpdServiceApiSample&lt;/h4&gt;
&lt;p&gt;The WpdServiceApiSample sample demonstrates how a developer would use the WPD API to explore a Contacts Device Service on a device that’s attached to a computer. For example, this application demonstrates how a developer would:&lt;/p&gt;

&lt;p&gt;· Enumerate the services on a devce.&lt;/p&gt;

&lt;p&gt;· Open a service.&lt;/p&gt;

&lt;p&gt;· Enumerate service content.&lt;/p&gt;

&lt;p&gt;· Retrieve the events and methods supported by a service.&lt;/p&gt;

&lt;p&gt;· Access the service object properties.&lt;/p&gt;

&lt;p&gt;· Invoke service methods (both synchronously and asynchronously).&lt;/p&gt;

&lt;p&gt;The WpdServiceApiSample application includes the following files: 
&lt;/p&gt;
&lt;table border="1" cellpadding="2" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;&lt;b&gt;File&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ContentEnumeration.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains methods that enumerate the content on a given Contacts service.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ContentProperties.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains methods that read and write properties on a given Contacts service.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ServiceCapabilities.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains the methods that retrieve the supported formats, events, and abstract services that are supported by a given Contacts service.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ServiceEnumeration.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains the helper functions that retrieve device information such as the device-friendly name or the supported Contacts services.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;ServiceMethods.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Contains the methods that retrieve and invoke methods supported by a given Contacts service.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;Stdafx.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Includes the standard files.&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
&lt;td valign="top" width="319"&gt;
&lt;p&gt;WpdServiceApiSample.cpp&lt;/p&gt;
&lt;/td&gt;

&lt;td valign="top" width="319"&gt;
&lt;p&gt;Displays a list of available device services and tasks available to the user&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;Because Device Services is new for Windows 7, this application is only supported in the Windows 7 operating system. &lt;/p&gt;

&lt;p&gt;Even if you have no WPD devices connected to your computer, you can familiarize yourself with the WPD API and this application by installing the WpdServiceSampleDriver that’s included as a sample in the Windows Driver Kit (WDK). This sample driver emulates a simple WPD device service. &lt;/p&gt;
&lt;h4&gt;Other Samples&lt;/h4&gt;
&lt;p&gt;In addition to the two samples that ship in the SDK, the WPD team created three other samples that demonstrate using WPD to display the current office temperature in the Windows Sidebar. One of these samples is written using unmanaged-code and C++; another is written using the COM interop and Visual Basic .Net; and, the third is written using the COM interop and Visual C# .Net.&lt;/p&gt;

&lt;p&gt;All three of these samples rely on a simple temperature sensor device, device-firmware, and a sample WPD driver. You can download the circuit description, device-firmware, and sample driver from here: &lt;a href="http://www.microsoft.com/whdc/device/media/WPD_drv.mspx" mce_href="http://www.microsoft.com/whdc/device/media/WPD_drv.mspx"&gt;http://www.microsoft.com/whdc/device/media/WPD_drv.mspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you build the device, download the firmware, and install the driver, you can begin exploring the WPD API samples. You’ll find a description of the unmanaged application at: &lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/12/19/creating-a-temperature-sensor-gadget-for-windows-sidebar-with-c.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/12/19/creating-a-temperature-sensor-gadget-for-windows-sidebar-with-c.aspx"&gt;http://blogs.msdn.com/wpdblog/archive/2007/12/19/creating-a-temperature-sensor-gadget-for-windows-sidebar-with-c.aspx&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You’ll find a description of the COM interop and Visual Basic .Net application at: &lt;a href="http://wpdtempsensor.codeplex.com/" mce_href="http://wpdtempsensor.codeplex.com/"&gt;http://wpdtempsensor.codeplex.com/&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;And, you’ll find a description of the COM interop and the C# application at: &lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/11/26/creating-a-temperature-sensor-gadget-for-windows-sidebar.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/11/26/creating-a-temperature-sensor-gadget-for-windows-sidebar.aspx"&gt;http://blogs.msdn.com/wpdblog/archive/2007/11/26/creating-a-temperature-sensor-gadget-for-windows-sidebar.aspx&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties and confers no rights.&lt;/i&gt;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9899742" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Windows 7 Portable Device Development Kits</title><link>http://blogs.msdn.com/wpdblog/archive/2009/09/11/windows-7-portable-device-development-kits.aspx</link><pubDate>Sat, 12 Sep 2009 09:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9894442</guid><dc:creator>wpdblog</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/9894442.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=9894442</wfw:commentRss><description>&lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;There are several different resources made available to portable device manufacturers to assist in device firmware and driver development, and to application developers wishing to create applications that interact with these portable devices. These resources are provided and maintained by members of the Windows Portable Devices team. &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;This post provides a description for the following development kits: &lt;/font&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpFirst"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;&lt;span style="font-family: symbol; mso-bidi-font-family: symbol; mso-fareast-font-family: symbol"&gt;&lt;span style="mso-list: ignore"&gt;&lt;span style="font: 7pt &amp;#39;Times New Roman&amp;#39;"&gt;&amp;#160;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Windows 7 Portable Device Enabling Kit for MTP &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Windows Portable Devices SDK &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Windows Portable Devices Driver Kit &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Windows Media Device Manager SDK &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;Microsoft Device Experience Development Kit &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt;    &lt;li&gt;     &lt;div style="text-indent: -0.25in; margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1" class="MsoListParagraphCxSpMiddle"&gt;&lt;font size="2"&gt;&lt;font face="Verdana"&gt;&lt;/span&gt;Windows Logo Kit &lt;/font&gt;&lt;/font&gt;&lt;/div&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;Windows 7 Portable Device Enabling Kit for MTP&lt;/h2&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;This development kit is designed to assist portable device manufacturers in the development of Media Transfer Protocol (MTP) device firmware that is compatible with the &lt;/font&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2009/08/29/mtp-over-various-transports.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2009/08/29/mtp-over-various-transports.aspx"&gt;&lt;font size="2"&gt;various MTP device transports that Windows supports&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;, and with &lt;/font&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2009/08/15/introducing-device-services.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2009/08/15/introducing-device-services.aspx"&gt;&lt;font size="2"&gt;Device Services&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. There are two packages provided for download: &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in"&gt;&lt;i&gt;&lt;font face="Verdana"&gt;Windows 7 Portable Device Enabling Kit for MTP - Tools&lt;/font&gt;&lt;/span&gt;&lt;/i&gt;&lt;font face="Verdana"&gt;      &lt;br /&gt;The tools kit includes design documentation and implementation guidelines, a Windows-based reference design, development tools, and the updated MTP Device Simulator. &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin-left: 0.5in"&gt;&lt;i&gt;&lt;font face="Verdana"&gt;Windows 7 Portable Device Enabling Kit for MTP - Reference Code&lt;/font&gt;&lt;/i&gt;&lt;font face="Verdana"&gt;      &lt;br /&gt;The reference code kit includes the core responder reference source code that is being made available under a separate Berkeley Software Distribution (BSD)–style license. &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;To download both packages of the Windows 7 Portable Device Enabling Kit for MTP, go to: &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://www.microsoft.com/whdc/device/wpd/MTP-DEK_Win7.mspx"&gt;http://www.microsoft.com/whdc/device/wpd/MTP-DEK_Win7.mspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;You are not required to license the reference code in order to use the tools and resources provided in the tools kit.&lt;span class="MsoCommentReference"&gt;&lt;span style="line-height: 115%; mso-bidi-font-size: 11.0pt; mso-ansi-font-size: 11.0pt"&gt; &lt;/span&gt;&lt;/span&gt;This kit is free to download and use.&lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;h2&gt;Windows Portable Devices SDK&lt;/h2&gt; &lt;span style="color: black"&gt;   &lt;p&gt;&lt;font size="2"&gt;The WPD SDK includes the WPD Application Programming Interface (API) that is supported in Windows 7, Windows Vista, and Windows XP operating Systems. Developers will use this API to write Windows applications in C++. &lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt;Being a COM API, the WPD API is also accessible from Managed code, so C# .Net, and Visual Basic .Net applications can use COM Interoperability to invoke the same functionality that the C++ API provides. WPD applications can: explore a device, send and receive content, and even control the device, for example, take a picture or send a text message.&lt;/font&gt;&lt;/p&gt; &lt;/span&gt;  &lt;p style="vertical-align: top"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;The WPD SDK includes two sample applications for C++/COM developers. The first, WpdApiSample, is a command-line desktop application that demonstrates how you would: enumerate connected devices, explore those devices, query device-objects for properties and attributes, send and retrieve data, and so on. The second sample, WpdServicesApiSample, is a command-line desktop application that demonstrates how you would explore a Contacts service on a device that is attached to your computer. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;The WPD SDK also includes an Automation Object Model that is supported in Windows 7. Developers can use the Automation model to write web applications that accomplish tasks similar to those accomplished with the API. We provided an introduction to WPD Automation in this recent &lt;/font&gt;&lt;/span&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2009/08/21/introducing-wpd-automation.aspxhttp:/blogs.msdn.com/wpdblog/archive/2009/08/21/introducing-wpd-automation.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2009/08/21/introducing-wpd-automation.aspxhttp:/blogs.msdn.com/wpdblog/archive/2009/08/21/introducing-wpd-automation.aspx"&gt;&lt;font color="#0080ff" size="2"&gt;post&lt;/font&gt;&lt;/a&gt;&lt;font size="3"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;.&lt;/font&gt; &lt;/span&gt;&lt;span style="color: black; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;span style="color: black"&gt;The WPD SDK is included in the Windows SDK which can be downloaded from &lt;/span&gt;&lt;font color="#0000ff"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505&amp;amp;displaylang=en&lt;/a&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="color: black"&gt;&lt;/span&gt; &lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;The documentation for the WPD SDK (both the API and Automation Object Model) is found on MSDN at: &lt;/font&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx"&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&lt;/a&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx"&gt;&lt;font size="2"&gt;http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx&lt;/font&gt;&lt;/a&gt;&lt;/a&gt;&lt;b&gt;&lt;span style="line-height: 140%; font-family: &amp;#39;Calibri&amp;#39;,&amp;#39;sans-serif&amp;#39;; color: black; font-size: 12pt; mso-bidi-font-size: 11.0pt"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;  &lt;h2&gt;Windows Portable Devices Driver Kit&lt;/h2&gt;  &lt;p&gt;&lt;font size="2" face="Verdana"&gt;The WPD Driver Kit includes a Device Driver Interface (DDI) that is supported in Windows 7, Windows Vista, and Windows XP operating Systems. Developers will use this DDI to write drivers for devices that are not already supported by the MTP or Mass Storage class drivers that Microsoft distributes.&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font size="2"&gt;The WPD Driver Kit includes five sample device drivers which are described in the following table. In the next &lt;/font&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2009/09/18/windows-7-driver-samples.aspx"&gt;&lt;font size="2"&gt;post&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;, we covered each sample in more detail.&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;/span&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;table style="border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in" class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0"&gt;&lt;tbody&gt;       &lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-top: black 1pt solid; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;b&gt;&lt;font size="2"&gt;Sample Driver&lt;/font&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-top: black 1pt solid; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;b&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 1"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;WpdHelloWorldDriver&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;This is the most basic WPD driver that emulates interaction with hardware. Supports four objects: device, storage, folder, and file. This provides the scaffolding or skeleton for developing a WPD driver.&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 2"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;WpdBasicHardwareDriver&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;Builds upon the WpdHelloWorldDriver and demonstrates interaction with simple hardware devices. Supports nine sensor devices: 2-axis accelerometer, 3-axis accelerometer, temperature/humidity sensor, pressure sensor, distance sensor, passive infrared sensor, compass, vibration sensor, and light sensor. These sensor devices are simple devices that are controlled by a Parallax BS2 microcontroller attached to the PC. &lt;/font&gt;&lt;/p&gt;            &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt;If you plan to develop drivers that integrate sensors with Windows 7, we recommend using the &lt;/font&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd318953(VS.85).aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd318953(VS.85).aspx"&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt;Sensor API&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt; and &lt;/font&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/cc974537.aspx" mce_href="http://msdn.microsoft.com/en-us/library/cc974537.aspx"&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt;Sensor Driver Model&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt;&lt;font size="2"&gt;. If you need to develop drivers to integrate sensors with Windows Vista or Windows XP, WPD provides a viable solution. &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 3"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;WpdServiceSampleDriver&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;Demonstrates how a developer would extend the WpdHelloWorldDriver to support a simulated device with a Contacts device service.(Using this service, WPD applications can discover events, methods, and properties associated with the Contacts stored on the device. This sample emulates interaction with hardware.&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 4"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;WpdMultiTransportDriver&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;Demonstrates how developers can take advantage of the Windows 7 support for multiple transports. The sample emulates interaction with hardware and demonstrates support for the following transports: IP, Bluetooth, and USB. We covered an overview of Multi-transport support in Windows 7 &lt;/font&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2009/09/04/multi-transport-devices-in-windows-7.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2009/09/04/multi-transport-devices-in-windows-7.aspx"&gt;&lt;font size="2"&gt;here&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;.&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;        &lt;tr style="mso-yfti-irow: 5; mso-yfti-lastrow: yes"&gt;         &lt;td style="border-bottom: black 1pt solid; border-left: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;WpdWudfSampleDriver&lt;span style="mso-ascii-font-family: calibri; mso-hansi-font-family: calibri; mso-bidi-font-family: calibri"&gt; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;          &lt;td style="border-bottom: black 1pt solid; padding-bottom: 0in; background-color: transparent; border-top-color: #f0f0f0; padding-left: 5.4pt; width: 239.4pt; padding-right: 5.4pt; border-left-color: #f0f0f0; border-right: black 1pt solid; padding-top: 0in" valign="top" width="319"&gt;           &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;A comprehensive sample driver that demonstrates what to enable in the WPD DDI for media transfer scenarios (such as music and photos). This sample supports media synchronization with Windows Media Player, and also emulates interaction with hardware.&lt;/font&gt;&lt;/p&gt;         &lt;/td&gt;       &lt;/tr&gt;     &lt;/tbody&gt;&lt;/table&gt; &lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;The WPD Driver Kit is included in the Windows Driver Kit (WDK). For information about downloading the WDK, see: &lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://www.microsoft.com/whdc/devtools/wdk/WDKpkg.mspx"&gt;http://www.microsoft.com/whdc/devtools/wdk/WDKpkg.mspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="color: black"&gt;&lt;font size="2"&gt;The documentation for the WPD Driver Kit is found on MSDN at: &lt;/font&gt;&lt;/span&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd419925.aspx"&gt;http://msdn.microsoft.com/en-us/library/dd419925.aspx&lt;/a&gt;&lt;/font&gt;&lt;span style="color: #1f497d"&gt;&lt;/span&gt; &lt;/p&gt;  &lt;h2&gt;Windows Media Device Manager SDK &lt;/h2&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The Windows Media Device Manager (WMDM) SDK &lt;span style="color: black"&gt;enables you to build desktop applications and components that can communicate with connected portable devices. WMDM enables your application or component to enumerate, explore, and exchange files with a device, query for metadata, and request play count information. Applications or components built on WMDM have a consistent API for communicating with a wide range of devices including Media Transfer Protocol (MTP), Mass Storage Class (MSC), RAPI, and other devices built on both the latest and previous versions of Windows Media technology. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"&gt;&lt;font size="2"&gt;The Windows Media Device Manager SDK is available at: &lt;/font&gt;&lt;/span&gt;&lt;a href="http://msdn.microsoft.com/en-us/windows/bb190309.aspx" mce_href="http://msdn.microsoft.com/en-us/windows/bb190309.aspx"&gt;&lt;font size="2"&gt;http://msdn.microsoft.com/en-us/windows/bb190309.aspx&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt;. &lt;/font&gt;&lt;/p&gt;  &lt;h2&gt;Microsoft Device Experience Development Kit&lt;/h2&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The Microsoft Device Experience Development Kit provides detailed information and material that you would need to know in order to develop Device Stage™ experiences for Portable Devices. The development kit includes device development guides, planning worksheets, tutorials, and development samples that you can use when developing a Device Stage experience on Windows 7. For portable devices, Device Stage supports the industry-standard Media Transfer Protocol (MTP) 1.0 with device services that enable a new rich set of features in Windows 7. &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The development kit along with other pertinent information to build a complete Windows Device Experience is available at: &lt;/font&gt;&lt;a href="http://www.microsoft.com/whdc/device/DeviceExperience/default.mspx" mce_href="http://www.microsoft.com/whdc/device/DeviceExperience/default.mspx"&gt;&lt;font size="2"&gt;http://www.microsoft.com/whdc/device/DeviceExperience/default.mspx&lt;/font&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The kit is free to download and use. &lt;/font&gt;&lt;/p&gt;  &lt;h2&gt;Windows Logo Kit&lt;/h2&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The primary use of the Windows Logo Kit (WLK) is for Windows Logo Program device certification. This kit can also be used for product development. We encourage its use during the product development cycle of hardware in order to ensure device compliance with both Windows and industry standards. The kit includes several tests designed to validate device implementation and behavior at multiple levels. There are tests for USB compliance, Media Transfer Protocol (MTP) compliance, and Windows Portable Devices (WPD) platform compliance that also cover device services validation.&lt;span style="mso-spacerun: yes"&gt;&amp;#160; &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;There is a significant amount of information available about the WLK, including user guides and video tutorials. For more information about the WLK see: &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://www.microsoft.com/whdc/winlogo/WLK/default.mspx"&gt;http://www.microsoft.com/whdc/winlogo/WLK/default.mspx&lt;/a&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;The kit is free to download and use.&lt;/font&gt; &lt;/p&gt;  &lt;h2&gt;Other Resources&lt;/h2&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;Windows Portable Devices node on Windows Hardware Developer Central &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;a href="http://www.microsoft.com/whdc/device/wpd/default.mspx" mce_href="http://www.microsoft.com/whdc/device/wpd/default.mspx"&gt;&lt;font size="2"&gt;http://www.microsoft.com/whdc/device/wpd/default.mspx&lt;/font&gt;&lt;/a&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font size="2"&gt;Windows Portable Devices on Microsoft Developer Network &lt;/font&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx&lt;/a&gt;&lt;/font&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p style="margin: 0in 0in 10pt" class="MsoNormal"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&lt;/span&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p mce_keep="true"&gt;&lt;span style="font-family: &amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;; font-size: 10pt"&gt;&lt;em&gt;This posting is provided &amp;quot;AS IS&amp;quot; with no warranties and confers no rights.&lt;/em&gt;&lt;/span&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9894442" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/MTP/default.aspx">MTP</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/Tools/default.aspx">Tools</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WMDM/default.aspx">WMDM</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/Device+Stage/default.aspx">Device Stage</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/Windows+7/default.aspx">Windows 7</category></item><item><title>Visual Basic .Net Sample for WPD</title><link>http://blogs.msdn.com/wpdblog/archive/2008/01/16/visual-basic-net-sample-for-wpd.aspx</link><pubDate>Wed, 16 Jan 2008 20:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7133124</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/7133124.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=7133124</wfw:commentRss><description>&lt;P&gt;We've created a Visual Basic .Net sample for WPD and posted it to CodePlex: Microsoft's open source project-hosting web site. Take a look at &lt;A href="http://www.codeplex.com/wpdtempsensor" mce_href="http://www.codeplex.com/wpdtempsensor"&gt;http://www.codeplex.com/wpdtempsensor&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;In addition to the Visual Basic project and source files, we've posted a document that describes the sample. This document also describes how you can address and resolve the COM Interop issues associated with .Net and WPD.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7133124" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category></item><item><title>Creating a Temperature Sensor Gadget for Windows Sidebar with C++</title><link>http://blogs.msdn.com/wpdblog/archive/2007/12/19/creating-a-temperature-sensor-gadget-for-windows-sidebar-with-c.aspx</link><pubDate>Thu, 20 Dec 2007 01:13:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6810306</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/6810306.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=6810306</wfw:commentRss><description>&lt;p&gt;&lt;span class="Bold"&gt;&lt;span style="font-family: Verdana; font-weight: normal;"&gt;The following post describes a gadget for Windows Sidebar that displays the temperature reading from a temperature sensor device. Similar applications could be written to display: battery-level or available memory for a portable media device, contact lists from a mobile phone or PDA, route lists from a GPS device, and so on.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span class="Bold"&gt;&lt;span style="font-family: Verdana; font-weight: normal;"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;h2 style="margin: 12pt 0in 8pt;"&gt;Introduction&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Microcontrollers are used in a variety of applications from industrial to automotive to the home. One use that stretches across these boundaries is the microcontroller-based sensor which monitors parameters such as temperature, humidity, acceleration, distance, and light.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;While the microcontroller device-universe has grown exponentially, there hasn’t been a common interface for integrating these devices with the PC. As a result, device and application developers were forced to write custom software to handle operations like data retrieval and display.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Microsoft recently introduced Microsoft® Windows® Portable Devices (WPD), a technology that addresses the challenges of integrating microcontroller-based devices with your PC. A microcontroller-based device can be as simple as a remote sensor or as complex as a mobile phone, a portable media player, or a digital camera. WPD consists of a driver model that runs in the user-mode driver framework (UMDF) and an API that simplifies the creation of applications for these devices.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This paper describes the use of the WPD API to create a Windows Console application that retrieves temperature data from a temperature sensor device. In addition, it describes a corresponding gadget for Windows Sidebar that consumes the data collected by the application.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor used by this application is based on the BASIC Stamp Activity Kit for Windows Portable Devices. This kit is offered by the Parallax Corporation in Rocklin, California. You can order the kit from the company’s &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98659" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98659"&gt;&lt;font color="#0000ff" face="Verdana"&gt;Web site&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The console application obtains real-time temperature data from a Parallax temperature sensor device. It writes this data to a file on disk. A script in the gadget’s HTML file retrieves the data and renders it in Windows Sidebar.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The console application was written in Microsoft Visual Studio® 8 using the C++ programming language. The WPD gadget was written in HTML and Jscript®. &lt;/font&gt;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;Downloading the Sample Application and Sidebar Gadget&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;To download the sample application, see this &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98948" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98948"&gt;&lt;font color="#0000ff" face="Verdana"&gt;page&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt; on the Microsoft Downloads site.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;To download the gadget, see this &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98949" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98949"&gt;&lt;font color="#0000ff" face="Verdana"&gt;page&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt; on the Microsoft Downloads site.&lt;/font&gt;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;Running the Sample Application&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample application requires that the WPD temperature sensor driver (WpdTempSensorDriver.dll) is installed and that a temperature sensor device is connected over a standard RS232 port.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The WPD temperature sensor driver exposes a Temperature Sensor object. This object, in turn, exposes three programmatic elements: two properties and an event. These elements are described in the following table.&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;Programmatic Element&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Interval property&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This read/write property specifies the frequency at which the device should return the current temperature. (This property is specified in milliseconds.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Temperature property&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This read-only property specifies the current temperature in degrees Kelvin.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Temperature-reading event&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This event is fired each time the device retrieves the current temperature. (The Interval property specifies the frequency at which the device will fire this event.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample console application, described in this white paper, registers to receive the Temperature-reading event notification each time it’s fired. Upon receiving the notification, the application writes the temperature data as HTML and saves it in an ASCII text file. The gadget, in turn, reads the HTML from this file and renders it in Sidebar.&lt;/font&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Building and Installing the Temperature Sensor Device&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor device referenced in this paper is based on a Parallax BS2 microcontroller and an AD592 Temperature Sensor transducer.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Parallax supplies a complete hardware kit that includes all of the required components. To order the kit, see this &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98659" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98659"&gt;&lt;font color="#0000ff" face="Verdana"&gt;page&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt; on the Parallax site.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;You can download the Basic Stamp source code for the temperature sensor device from the &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98661" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98661"&gt;&lt;font color="#0000ff" face="Verdana"&gt;WHDC site&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&lt;/font&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Building and Installing the WPD Temperature Sensor Driver&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;In order to install the driver, download the source code and build it. For information about downloading the driver, see the following topic on the &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98661" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98661"&gt;&lt;font color="#0000ff" face="Verdana"&gt;WHDC Web site&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&lt;/font&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Installing the Gadget&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The download package referenced above in this article contains a file named WpdTemperatureSensor.gadget. Copy this file to your local machine, open Windows Explorer, and double-click this file. You will be asked whether you want to install the gadget. Click Install. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The gadget will be installed in the Desktop\&lt;user name=""&gt;\AppData\Local\Microsoft\Windows Sidebar\Gadgets folder.&lt;/user&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Now you’re ready to build and run the sample application.&lt;/font&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Building and Running the Sample Application&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The download package included with this white paper contains the project, source, and header files for the sample console application that retrieves temperature data from the sensor. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;After you’ve installed the temperature sensor device, driver, and gadget files, you’ll need to extract the contents of the download package to your development machine. This includes the following files.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;stdafx.h&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;stdafx.cpp&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;deviceevents.cpp&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;sidebar_console.cpp&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;sidebar_console.vcproj&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;For a description of these files, see the Temperature Sensor Console Application section that follows. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;If you haven’t installed the Windows SDK for Windows Vista, you’ll need to do so before building the project. For information about installing the Windows SDK, visit the &lt;a href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx" title="Windows SDK web page" mce_href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx"&gt;Windows SDK web page&lt;/a&gt;&lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98663" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98663"&gt;&lt;font color="#0000ff" face="Verdana"&gt;&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Once the Windows SDK is installed, open the project file (sidebar_console.vcproj) in Visual Studio 8. Select the Build_Sidebar console option from the Build menu. Visual Studio 8 will build an executable file and place it in the \Debug subdirectory. You can test the gadget and verify that it works by selecting Start Debugging from the Debug menu.&lt;/font&gt;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;WPD Application and Gadget Overview&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The WPD application and gadget consists of two separate processes: a server and a client. The server is a console application which monitors the temperature sensor device for event notifications. Each time this application receives a notification, it writes corresponding temperature data formatted as HTML to a file on disk. The client is a script running in the gadget’s HTML file. This script retrieves the data from the file created by the console application and renders it in Sidebar. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The WPD Console Application registers to receive temperature events from the device. These events are fired at an interval specified by the device’s Interval property. (The default value for this property is 2,000 milliseconds.)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The event handler in the console application writes the temperature as a string of HTML to an ASCII text file on the local disk. This string has the following appearance.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;P&amp;gt;Office Temperature&amp;lt;P&amp;gt;304&amp;amp;deg; Kelvin&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The gadget’s script executes every 3,000 milliseconds. The script reads the string of HTML created by the console application and inserts that string into the body of the gadget’s HTML.&lt;/font&gt;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;The Temperature Sensor Console Application&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor console application is a simple application that accomplishes the following tasks.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Searches for the temperature sensor device and opens a connection if the device is found.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Registers to receive event notifications from the device.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Enters a loop and responds to any one of three inputs from the user.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;While listening for user input, and for as long as the event registration is intact, writes temperature data to the local disk.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor application project consists of the following files:&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;File&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;stdafx.h&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Contains #defines for the target platform as well as #includes for the standard system include file.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;deviceevents.cpp&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Implements &lt;b style=""&gt;IPortableDeviceEventCallback&lt;/b&gt; which is required by any WPD application that registers to receive device events.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;sidebar_console.cpp&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Implements the entry point for the console application and the helper functions which perform tasks like searching for the device and establishing a connection. &lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;stdafx.cpp&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Contains #include for stdafx.h&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;sidebar_console.vcproj&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The Visual Studio 8 project file.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Most of work accomplished by the application is found in the module named sidebar_console.cpp; the exception is the event handling code which is found in the module deviceevents.cpp.&lt;/font&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Opening a Connection to the Temperature Sensor Device&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The WPD API provides a set of interfaces that a Windows programmer can use to accomplish tasks like enumerating connected devices, opening a device, closing a device, enumerating objects on a device, reading and writing properties on a device, sending a command to a device, and registering to receive events from a device.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;One of the primary interfaces is the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDevice&lt;/b&gt;&lt;/span&gt; interface which supports the methods a programmer calls to open a device, receive events, send a command, and so on. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The first task the sample application accomplishes is to open (establish a connection to) the temperature sensor device. It does this by calling the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDevice::Open&lt;/b&gt;&lt;/span&gt; method. This method takes two parameters: a pointer to a string that specifies a special identifier for the device and a pointer to an array of key/value pairs that specify information about the calling application.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;hr = CoCreateInstance(CLSID_PortableDevice,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NULL,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CLSCTX_INPROC_SERVER,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;IID_IPortableDevice,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(VOID**) &amp;amp;pIPortableDevice);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (SUCCEEDED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pIPortableDevice != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = (pIPortableDevice)-&amp;gt;Open(DeviceID, pClientInformation);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Release the IPortableDevice interface&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;// because we cannot proceed with an&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// unopen device.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pIPortableDevice = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("Device successfully opened.\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;br&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;In order to retrieve the device identifier &lt;span class="Italic"&gt;&lt;i&gt;DeviceID&lt;/i&gt;&lt;/span&gt;, which is passed as the first parameter to &lt;span class="Bold"&gt;&lt;b&gt;IPortableDevice::Open&lt;/b&gt;&lt;/span&gt;, the application first needs to determine whether the temperature sensor device is connected to the PC and, if it is, retrieve the identifier. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; helper function in the Sidebar_Console.cpp module accomplishes this work. The &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; function has two arguments: the first is a “friendly” name for the target device; the second is the special Plug and Play identifier that the WPD API returns as a match for this friendly name.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; helper function accomplishes the following tasks.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;1.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;Retrieves a count of devices connected to the PC.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;2.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Retrieves an array of friendly names for each device.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;3.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Compares the friendly name passed in its first argument to the friendly names for each of the connected devices.If a match is found, it retrieves the Plug and Play identifier for the target device.&lt;/font&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Retrieving a Count of Connected Devices&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The first task of the &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; function is the retrieval of a count of connected devices. This is done in two stages: first, by creating an &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceManager&lt;/b&gt;&lt;/span&gt; object, and second, by calling the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceManager::GetDevices&lt;/b&gt;&lt;/span&gt; method. (In order to retrieve a count of connected devices, the first argument to &lt;span class="Bold"&gt;&lt;b&gt;GetDevices&lt;/b&gt;&lt;/span&gt; is set to NULL.)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;// CoCreate the IPortableDeviceManager interface to enumerate&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;// portable devices and to get information about them.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;hr = CoCreateInstance(CLSID_PortableDeviceManager,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NULL,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CLSCTX_INPROC_SERVER,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;IID_IPortableDeviceManager,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;(VOID**) &amp;amp;pPortableDeviceManager);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to CoCreateInstance CLSID_PortableDeviceManager\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return hr;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;// First, pass NULL as the LPWSTR array pointer to get the total&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;// number of devices found on the system.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;if (SUCCEEDED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pPortableDeviceManager-&amp;gt;GetDevices(NULL, &amp;amp;cPnPDeviceIDs);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to get number of devices on the system\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return hr;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Retrieving a Plug and Play name for the Temperature Sensor&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;WPD supports two types of device names: friendly names and Plug and Play names. The friendly names are the names applications display to the user. The friendly name for the temperature sensor device is: "Parallax BS2 Temperature Sensor". The Plug and Play names are used internally by WPD to identify devices.&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;The Plug and Play name for the temperature sensor device is: &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;a href="file:///%5C%5C%3f%5Croot#wpd#0000#%7B6ac27878-a6fa-4155-ba85-f98f491d4f33%7D" mce_href="file:///\\%3f\root#wpd#0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}"&gt;&lt;span style="color: black; text-decoration: none;"&gt;&lt;font face="Courier New"&gt;\\?\root#wpd#0000#{6ac27878-a6fa-4155-ba85-f98f491d4f33}&lt;/font&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This string uniquely identifies the device instance and the device interface, and it is defined as part of the Windows Driver Model (WDM). For more information, refer to this &lt;/font&gt;&lt;a href="http://go.microsoft.com/fwlink/?LinkId=98665" target="_blank" mce_href="http://go.microsoft.com/fwlink/?LinkId=98665"&gt;&lt;font color="#0000ff" face="Verdana"&gt;MSDN topic&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;After retrieving a count of connected devices and storing it in the cPnPDeviceIDs variable, &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; iterates through the available devices until it finds a device whose friendly name matches the string “Parallax BS2 Temperature Sensor”. If this match is made, &lt;span class="Bold"&gt;&lt;b&gt;FindDevice&lt;/b&gt;&lt;/span&gt; returns the corresponding Plug and Play name in the DeviceID argument. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (cPnPDeviceIDs &amp;gt; 0)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pPnpDeviceIDs = new LPWSTR[cPnPDeviceIDs];&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pPnpDeviceIDs != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD dwIndex = 0;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pPortableDeviceManager-&amp;gt;GetDevices(pPnpDeviceIDs, &amp;amp;cPnPDeviceIDs);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (SUCCEEDED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// For each device found, retrieve the friendly&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// name and compare it to the submitted name.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for (dwIndex = 0; dwIndex &amp;lt; cPnPDeviceIDs; dwIndex++)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CAtlStringW FriendlyName;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = RetrieveFriendlyName(pPortableDeviceManager, pPnpDeviceIDs[dwIndex], FriendlyName);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;if ((hr == S_OK) &amp;amp;&amp;amp; (DeviceName.CompareNoCase(FriendlyName) == 0))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DeviceID = pPnpDeviceIDs[dwIndex];&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;bFoundDevice = TRUE;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;break;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to get the device list from the system\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (SUCCEEDED(hr) &amp;amp;&amp;amp; (!bFoundDevice))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to find a matching device\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = E_FAIL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Free all returned PnPDeviceID strings by using&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// CoTaskMemFree.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;// NOTE: CoTaskMemFree can handle NULL pointers, so&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;no NULL check is needed.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;for (dwIndex = 0; dwIndex &amp;lt; cPnPDeviceIDs; dwIndex++)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CoTaskMemFree(pPnpDeviceIDs[dwIndex]);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pPnpDeviceIDs[dwIndex] = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Delete the array of LPWSTR pointers.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delete [] pPnpDeviceIDs;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pPnpDeviceIDs = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to allocate memory for LPWSTR array\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = E_OUTOFMEMORY;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return hr;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The application passes the returned Plug and Play name as the first argument to &lt;b style=""&gt;IPortableDevice::Open&lt;/b&gt; when it opens the device.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Note that the FindDevice function calls the RetrieveFriendlyName helper function to retrieve a friendly name for each Plug and Play name returned by IPortableDeviceManager::GetDevices. The RetrieveFriendlyName function calls the IPortableDeviceManager::GetFriendlyName method twice to retrieve the friendly name string. The first time, it calls this method to retrieve a count of characters in the friendly name string; the second time, it calls this method to retrieve the actual string.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// First, pass NULL as the LPWSTR return string parameter to get&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// the total number of characters to allocate for the string&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// value.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pPortableDeviceManager-&amp;gt;GetDeviceFriendlyName(pPnPDeviceID, NULL, &amp;amp;cchFriendlyName);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to get number of characters for device friendly name.\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return hr;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Second, allocate the number of characters needed and retrieve&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// the string value.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if ((hr == S_OK) &amp;amp;&amp;amp; (cchFriendlyName &amp;gt; 0))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;wszFriendlyName = new WCHAR[cchFriendlyName];&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (wszFriendlyName != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pPortableDeviceManager-&amp;gt;GetDeviceFriendlyName(pPnPDeviceID, wszFriendlyName, &amp;amp;cchFriendlyName);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (SUCCEEDED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FriendlyName = wszFriendlyName;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to get device friendly name\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Delete the allocated friendly name string.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;delete [] wszFriendlyName;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;wszFriendlyName = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;br&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Receiving Device Events&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The WPD API and driver model were designed so devices can issue events and applications can register to receive notifications when these events occur. Applications that receive events must implement the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceEventCallback&lt;/b&gt;&lt;/span&gt; interface. This interface supports a single &lt;span class="Bold"&gt;&lt;b&gt;OnEvent&lt;/b&gt;&lt;/span&gt; method. The driver calls this method each time an event is fired. However, in order for a driver to call this method, an application first needs to register with the driver. An application registers with the driver by calling the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDevice::Advise&lt;/b&gt;&lt;/span&gt; method. The third argument for this method, &lt;span class="Italic"&gt;&lt;i&gt;pCallback&lt;/i&gt;&lt;/span&gt;, is a pointer to the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceEventCallback&lt;/b&gt;&lt;/span&gt; interface that the application implemented.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor device issues a single temperature-reading event that the sample application registers to receive. Each time the driver calls the &lt;span class="Bold"&gt;&lt;b&gt;OnEvent&lt;/b&gt;&lt;/span&gt; method, the sample application writes the received temperature to a local file on disk. The gadget’s script then reads from this file to update the gadget with the most recent office temperature.&lt;/font&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Implementing IPortableDeviceEventCallback&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample application implements the &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceEventCallback&lt;/b&gt;&lt;/span&gt; interface in the DeviceEvents.cpp module. Most of the code in this module was taken from the WpdApiSample application that ships with the Windows SDK. The following changes were made to the original file.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;The TEMPERATURE_SENSOR_READING property key was defined and declared.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;The &lt;span class="Bold"&gt;&lt;b&gt;OnEvent&lt;/b&gt;&lt;/span&gt; method was modified to process the TEMPERATURE_SENSOR_READING property and write the new temperature value to disk.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The &lt;span class="Bold"&gt;&lt;b&gt;IPortableDeviceEventCallback&lt;/b&gt;&lt;/span&gt; interface is implemented in the &lt;span class="Bold"&gt;&lt;b&gt;CPortableDeviceEventsCallback&lt;/b&gt;&lt;/span&gt; class in DeviceEvents.cpp. This class supports the following methods.&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Method&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;CPortableDeviceEventsCallback&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Object constructor&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;~CPortableDeviceEventsCallback&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Object destructor&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;QueryInterface&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Returns a pointer to the &lt;b style=""&gt;IPortableDeviceEventCallback&lt;/b&gt; interface.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;AddRef&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Increments the object’s reference count.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;Release&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Decrements the object’s reference count.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;OnEvent&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Event handler. WPD will call this method if the application is registered to receive event notifications.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;In addition to implementing &lt;b style=""&gt;IPortableDeviceEventCallback&lt;/b&gt;, the DeviceEvents.cpp module also contains two functions that the application calls in order to register and unregister for event notifications. These functions are described in the following table.&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Function&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;RegisterForEventNotifications&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Registers the application to receive event notifications. (This method is called when the application first starts.It’s also called if the user requests registration by entering the number &lt;b&gt;2&lt;/b&gt; at the command prompt.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;b style=""&gt;&lt;font face="Verdana"&gt;UnregisterForEventNotifications&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Unregisters the application from receiving event notifications. (This method is called if the user requests cancellation of registration by entering the number &lt;b&gt;1&lt;/b&gt; at the command prompt.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Implementing the IPortableDeviceEventCallback::OnEvent Method&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Once an application registers to receive event notifications, the WPD device driver will call the &lt;b style=""&gt;IPortableDeviceEventCallback::OnEvent&lt;/b&gt; method whenever the device fires an event. Each time the driver calls this method, it passes data associated with the given event in an &lt;b style=""&gt;IPortableDeviceValues&lt;/b&gt; interface. The &lt;i style=""&gt;pEventParameters&lt;/i&gt; argument is a pointer to this interface.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor device fires one event per temperature reading update, and the accompanying data is a single, signed integer value which specifies the current temperature in degrees Kelvin. The sample application retrieves this value by calling the IPortableDeviceValues::GetSignedIntegerValue method and passing the property key for the TEMPERATURE_SENSOR_READING property as the first argument. (This property key was declared and defined at the top of DeviceEvents.cpp.)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;HRESULT __stdcall OnEvent(&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;IPortableDeviceValues* pEventParameters)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HRESULT hr = S_OK;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LONG i=0;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HANDLE hFile;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD dwBytesWritten;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;char strHtmlPrefix[]="&amp;lt;P&amp;gt;Office Temperature&amp;lt;P&amp;gt;";&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;char strHtmlSuffix[]="&amp;amp;deg; Kelvin";&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;char strHtml[40];&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pEventParameters != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pEventParameters-&amp;gt;GetSignedIntegerValue(TEMPERATURE_SENSOR_READING, &amp;amp;i);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;sprintf_s(strHtml, "%s%d%s\0", strHtmlPrefix, i, strHtmlSuffix);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hFile = CreateFileW(_T("c:\\temp\\tempdata.txt"),&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;GENERIC_WRITE,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;0,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NULL,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CREATE_ALWAYS,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FILE_ATTRIBUTE_NORMAL,&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NULL);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (WriteFile(hFile, strHtml, sizeof(strHtml), &amp;amp;dwBytesWritten, NULL))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("Current temperature: %d Kelvin\n\r", i);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("Temperature written to target file.\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("Temperature not written to target file.\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("WriteFile failed with error %d.\n\r\n\r", GetLastError());&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CloseHandle(hFile); // We need to close the handle.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return hr;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Upon retrieving the current temperature, the &lt;b style=""&gt;OnEvent&lt;/b&gt; method writes a string of HTML to a temporary file on disk (c:\temp\tempdata.txt). The gadget reads this string of HTML from the temporary file and incorporates it into the gadget’s own HTML. In addition, the &lt;b style=""&gt;OnEvent&lt;/b&gt; method writes the current temperature to the console window.&lt;/font&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Implementing the RegisterForEventNotifications Function&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample application supports a single function, &lt;b style=""&gt;RegisterForEventNotfications&lt;/b&gt;, which it calls at startup and if the user explicitly requests registration. This function performs the following tasks.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;4.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Examines the event registration cookie (g_strEventRegistrationCookie) to determine whether the application is already registered.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;5.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;If not, creates an instance of the CPortableDeviceEventsCallback object.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;6.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Calls the IPortableDevice::Advise method to complete the registration.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;7.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;If registration is successful, assigns the event cookie returned by the Advise method to the &lt;i style=""&gt;g_strEventRegistrationCookie&lt;/i&gt; variable.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;void RegisterForEventNotifications(IPortableDevice* pDevice)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HRESULT&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = S_OK;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;LPWSTR&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;wszEventCookie = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CPortableDeviceEventsCallback* pCallback = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pDevice == NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Check to see if we already have an event registration cookie.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// If so, then avoid registering again.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// NOTE: An application can register for events as many times as.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;wanted. This sample only keeps a single registration&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;//&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;cookie around for simplicity.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (g_strEventRegistrationCookie.GetLength() &amp;gt; 0)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("This application has already registered to receive device events.\n\r\n\r");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Create an instance of the callback object. This will be&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// called when events are received.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (hr == S_OK)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pCallback = new CPortableDeviceEventsCallback();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pCallback == NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = E_OUTOFMEMORY;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("Failed to allocate memory for IPortableDeviceEventsCallback object, hr = 0x%lx\n\r\n\r",hr);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Call Advise to register the callback and receive events.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (hr == S_OK)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pDevice-&amp;gt;Advise(0, pCallback, NULL, &amp;amp;wszEventCookie);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to register for device events, hr = 0x%lx\n\r\n\r",hr);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Save the event registration cookie if event registration was&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// successful.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (hr == S_OK)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;g_strEventRegistrationCookie = wszEventCookie;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Free the event registration cookie if one was returned.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (wszEventCookie != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CoTaskMemFree(wszEventCookie);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;wszEventCookie = NULL;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (hr == S_OK)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("This application has registered for device event notifications.\r\n\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// If a failure occurs, remember to delete the allocated callback&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// object if one exists.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pCallback != NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pCallback-&amp;gt;Release();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;h4 style="margin: 12pt 0in 8pt;"&gt;&lt;u&gt;&lt;font size="2"&gt;Implementing the UnregisterForEventNotifications Function&lt;/font&gt;&lt;/u&gt;&lt;/h4&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample application supports a single function, UnregisterForEventNotfications, which it calls if the user explicitly cancels registration. This function performs the following tasks.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;8.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Calls the IPortableDevice::Unadvise method and passes the registration cookie (which is also the event cookie returned by the IPortableDevice::Advise method).&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="NumberedList1"&gt;&lt;span style=""&gt;&lt;span style=""&gt;&lt;font face="Verdana"&gt;9.&lt;/font&gt;&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;Sets the internal event registration-cookie variable g_strEventRegistrationCookie to an empty string.&lt;/font&gt;&lt;/p&gt;

&lt;br&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;void UnregisterForEventNotifications(IPortableDevice* pDevice)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HRESULT hr = S_OK;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (pDevice == NULL)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = pDevice-&amp;gt;Unadvise(g_strEventRegistrationCookie);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (FAILED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to unregister for device events using registration cookie '%ws', hr = 0x%lx\n\r\n\r",g_strEventRegistrationCookie.GetString(), hr);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (hr == S_OK)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("This application used the registration cookie '%ws' to unregister from receiving device event notifications\n\r\n\r", g_strEventRegistrationCookie.GetString());&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;g_strEventRegistrationCookie = L"";&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Handling User Input&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The sample application displays a simple menu in the console window when it begins execution. This menu has three options corresponding to three integer values.&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Option/Value&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;1&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Unregister for device notifications. (The application calls the &lt;b&gt;UnregisterForEventNotifications&lt;/b&gt; function.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;2&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Register for device notifications. (The application calls the &lt;span class="Bold"&gt;&lt;b&gt;RegisterForEventNotifications&lt;/b&gt;&lt;/span&gt; function.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;99&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;Exit. (The application exits.)&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The code that supports the menu and its options is found in the &lt;b style=""&gt;ProcessInput&lt;/b&gt; function in the Sidebar_Console.cpp module.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;void ProcessInput(CComPtr&amp;lt;IPortableDevice&amp;gt; pIPortableDevice)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;HRESULT hr&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;= S_OK;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;UINT&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;uiSelection&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;= 0;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;CHAR&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;szSelection[81] = {0};&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("\n\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("===============================================\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("1.&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;Unregister for device notifications.\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("2.&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;Register for device notifications.\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("99. Exit.\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("===============================================\r\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("\n\n");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;while (uiSelection != 99)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;ZeroMemory(szSelection, sizeof(szSelection));&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;span style=""&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;hr = StringCbGetsA(szSelection,sizeof(szSelection));&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;if (SUCCEEDED(hr))&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;uiSelection = (UINT) atoi(szSelection);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;switch (uiSelection)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;case 1:&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Unregister to receive device events&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;UnregisterForEventNotifications(pIPortableDevice);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;break;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;case 2:&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;// Register to receive device events&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;RegisterForEventNotifications(pIPortableDevice);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;default:&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;break;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;else&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;printf("! Failed to read menu selection string input, hr = 0x%lx\n\r\n\r",hr);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;The Temperature Sensor Gadget&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt 9pt;" class="Figure"&gt;&lt;font face="Verdana"&gt;The temperature sensor gadget displays the current office temperature in degrees Kelvin in Windows Sidebar. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;If you’ve never created a gadget for Windows Sidebar before, refer to the &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa965850.aspx" target="_blank" mce_href="http://msdn2.microsoft.com/en-us/library/aa965850.aspx"&gt;&lt;font face="Verdana"&gt;Gadget Development Overview&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;The Temperature Sensor Gadget Files&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The temperature sensor gadget consists of three files: an HTML file, an XML file, and a JPEG file. These files are described in the following table.&lt;/font&gt;&lt;/p&gt;

&lt;table style="border-collapse: collapse;" class="MsoNormalTable" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;File Name&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border-style: none none solid; border-color: rgb(212, 208, 200) rgb(212, 208, 200) windowtext; border-width: medium medium 1pt; padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Label"&gt;&lt;b&gt;&lt;font face="Verdana"&gt;Description&lt;/font&gt;&lt;/b&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;UpdateTemperatureReading.htm&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;An HTML file that contains the script which retrieves the updated temperature data from the local disk every 3,000 milliseconds. &lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;gadget.xml&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The gadget manifest. This file specifies properties such as the name of the gadget, the name of its HTML file, a string of descriptive text, and so on.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;

&lt;tr style=""&gt;
&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;background.jpg&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;

&lt;td style="border: medium none rgb(212, 208, 200); padding: 0pt 4pt; background-color: transparent; width: 223pt;" valign="top" width="297"&gt;
&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;A 163 x 58 pixel image that produces the gadget’s two-tone blue background color.&lt;/font&gt;&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p style="margin: 3pt 0pt 0pt;" class="TableSpacingAfter"&gt;&lt;o:p&gt;&lt;font size="1" color="#ffff00" face="Verdana"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;h3 style="margin: 12pt 0in 8pt;"&gt;&lt;b&gt;&lt;font size="3"&gt;Retrieving the Current Temperature&lt;/font&gt;&lt;/b&gt;&lt;/h3&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The gadget’s HTML file, UpdateTemperatureReading.htm, contains a script which opens the file created by the console application (c:\temp\tempdata.txt) and copies the contents of this file into a span element identified as “temperature_data” within the body of the gadget’s HTML.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;This script creates a FileSystemObject which it uses to open and read the text file. It uses the OpenTextFile method to open the file and the ReadAll method to retrieve its contents. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The script uses the setTimeout method on the window object to recursively execute the update function every 3,000 milliseconds. (This function contains the code that retrieves the contents of c:\temp\tempdata.txt.)&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;html&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;head&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;script&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;var fileSystemObject = null;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;function loaded()&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;update();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;function update()&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;var textStream = fileSystemObject.OpenTextFile("c:\\temp\\tempdata.txt");&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;try&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;temperature_data.innerHTML = textStream.ReadAll();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;finally&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;textStream.Close();&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;window.setTimeout(update, 3000);&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/script&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;style&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;body &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{ &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;margin: 0;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;width: 125px;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;height: 62px;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;font: 'normal 8pt Arial';&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;line-height: 12pt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;text-align:center;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/style&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/head&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;o:p&gt;&lt;font face="Courier New"&gt;&amp;nbsp;&lt;/font&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;body onload="loaded()"&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;g:background src="background.png"&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;span id="temperature_data"&amp;gt;&amp;lt;/span&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/g:background&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/body&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&lt;font face="Courier New"&gt;&amp;lt;/html&amp;gt;&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 0pt 0pt 3pt;" class="Code"&gt;&amp;nbsp;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The HTML file also contains a description of the gadget’s window between the &amp;lt;style&amp;gt; and &amp;lt;/style&amp;gt; tags that follow the script. Note that the width and height attributes match the width and height of the background image (background.png). In addition to specifying the size of the gadget’s window, the attributes found here specify the font used to render text, the line height (which creates padding between the two lines of text), and the text alignment. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The g:background element specifies the source file (background.png) for the gadget’s background image. &lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&lt;font face="Verdana"&gt;The span element “temperature_data” identifies the location of the HTML which is copied from c:\temp\tempdata.txt by the Update function.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt;" class="Text"&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2 style="margin: 12pt 0in 8pt;"&gt;More Information&lt;/h2&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;For general information about developing gadgets for Windows Sidebar, see the &lt;/font&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa965850.aspx" target="_blank" mce_href="http://msdn2.microsoft.com/en-us/library/aa965850.aspx"&gt;&lt;font face="Verdana"&gt;Gadget Development Overview&lt;/font&gt;&lt;/a&gt;&lt;font face="Verdana"&gt;.&lt;/font&gt;&lt;/p&gt;

&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&lt;span style="font-family: Symbol; color: windowtext;"&gt;&lt;span style=""&gt;·&lt;span style="font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;font face="Verdana"&gt;To learn more about &lt;span style="color: windowtext;"&gt;the BASIC Stamp Activity Kit for Windows Portable Devices, refer to the &lt;a href="http://go.microsoft.com/fwlink?linkid=98659" target="_blank " mce_href="http://go.microsoft.com/fwlink?linkid=98659"&gt;&lt;font color="#0000ff"&gt;Parallax site&lt;/font&gt;&lt;/a&gt;.&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="margin: 3pt 0pt 3pt 18pt;" class="BulletedList1"&gt;&amp;nbsp;&lt;/p&gt;


&lt;p&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no 
rights.&lt;/i&gt;&lt;/p&gt;

&lt;p style="margin: 0in 0in 8pt;" class="MsoNormal"&gt;&amp;nbsp;&lt;/p&gt;
&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=6810306" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category></item><item><title>New Driver and Application Whitepapers Are Here</title><link>http://blogs.msdn.com/wpdblog/archive/2007/05/07/wpd-whitepapers.aspx</link><pubDate>Mon, 07 May 2007 21:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2466855</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/2466855.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=2466855</wfw:commentRss><description>&lt;P&gt;We've published two new WPD developer-centric&amp;nbsp;whitepapers at the Microsoft WHDC website for WinHEC.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first&amp;nbsp;covers how to do WMDRM metering and license synchronization from a WPD application; the second&amp;nbsp;describes how to port the existing WPD "Hello World" sample driver to communicate with a Parallax Basic Stamp II microcontroller to&amp;nbsp;read temperature sensor data.&amp;nbsp;&amp;nbsp; Both contain sample code.&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I. Accessing WMDRM APIs from a WPD Application:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/whdc/device/media/WMDRM_API.mspx" mce_href="http://www.microsoft.com/whdc/device/media/WMDRM_API.mspx"&gt;http://www.microsoft.com/whdc/device/media/WMDRM_API.mspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;This whitepaper describes how to associate a WPD device instance with a WMDM device instance for MTP devices; the WMDM device instance is then&amp;nbsp;used&amp;nbsp;for calling Windows Media Digital Rights Management (WMDRM) application interfaces. To&amp;nbsp;build the sample WPD application, you need the Windows Media Format SDK v11 and the Windows SDK (v6000).&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;II. Creating a WPD Driver for a Microcontroller-Based Sensor:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/whdc/device/media/WPD_drv.mspx" mce_href="http://www.microsoft.com/whdc/device/media/WPD_drv.mspx"&gt;http://www.microsoft.com/whdc/device/media/WPD_drv.mspx&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;This sample is based on the Parallax Basic Stamp II microcontroller to provide an example of a simple hardware device that&amp;nbsp;can have a WPD driver for it.&amp;nbsp;&amp;nbsp; Parallax provides an &lt;A class="" title="Basic Stamp Activity Kit for Windows Portable Devices" href="http://www.parallax.com/detail.asp?product_id=910-90005" mce_href="http://www.parallax.com/detail.asp?product_id=910-90005"&gt;activity kit&lt;/A&gt; that contains the hardware components for this sample&amp;nbsp;driver.&amp;nbsp; To&amp;nbsp;build the driver,&amp;nbsp;you need the&amp;nbsp;Windows Driver Kit&amp;nbsp;(v6000).&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;References&lt;/STRONG&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;All WPD-related whitepapers are posted &lt;A class="" title="Windows Portable Devices Whitepapers" href="http://www.microsoft.com/whdc/device/netAttach/default.mspx" mce_href="http://www.microsoft.com/whdc/device/netAttach/default.mspx"&gt;here&lt;/A&gt;.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;A class="" title="Downloading WPD for Development" href="http://blogs.msdn.com/controlpanel/blogs/To%20download%20the%20pre-requisities,%20see%20http://blogs.msdn.com/wpdblog/pages/downloading-wpd-for-development.aspx" mce_href="To download the pre-requisities, see http://blogs.msdn.com/wpdblog/pages/downloading-wpd-for-development.aspx"&gt;More information&lt;/A&gt; on downloading the various SDKs.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;EM&gt;&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2466855" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WDK/default.aspx">WDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WMDM/default.aspx">WMDM</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/DRM/default.aspx">DRM</category></item><item><title>WPD and WMDM Side-by-side: An Application Development Perspective</title><link>http://blogs.msdn.com/wpdblog/archive/2007/03/24/wpd-and-wmdm-side-by-side-application-development.aspx</link><pubDate>Sat, 24 Mar 2007 20:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1943316</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1943316.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1943316</wfw:commentRss><description>&lt;p&gt;This post will compare&amp;nbsp;WPD and the latest version of &lt;a href="http://msdn2.microsoft.com/en-us/library/bb231982.aspx" class="" title="Windows Media Device Manager 11" mce_href="http://msdn2.microsoft.com/en-us/library/bb231982.aspx"&gt;Windows Media Device Manager (WMDM)&lt;/a&gt;,&amp;nbsp;from an application developer's point of view.&lt;/p&gt;
&lt;p&gt;&lt;u&gt;&lt;b&gt;Availability (aka SDK and Runtime Requirements)&lt;/b&gt;&lt;/u&gt;&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx" title="Windows SDK" mce_href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx"&gt;Windows SDK&lt;/a&gt; contains the complete build environment&amp;nbsp;(headers, libs, sample code ...)&amp;nbsp;for&amp;nbsp;developing&amp;nbsp;a WPD application&amp;nbsp;for both 32 and 64-bit.&lt;/p&gt;
&lt;p&gt;The &lt;a href="http://msdn2.microsoft.com/en-us/windowsmedia/bb190309.aspx" class="" title="Windows Media Downloads" mce_href="http://msdn2.microsoft.com/en-us/windowsmedia/bb190309.aspx"&gt;Windows Media Format 11 SDK&lt;/a&gt;&amp;nbsp;(WMFSDK11) provides&amp;nbsp;headers and libs for WMDM 11.&amp;nbsp;&amp;nbsp;Since&amp;nbsp;WMFSDK11&amp;nbsp;is released in 32-bit, only 32-bit WMDM applications can be built.&amp;nbsp; On 64-bit Windows,&amp;nbsp;a 32-bit&amp;nbsp;WMDM application will run in SysWOW mode.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="border: medium none ; border-collapse: collapse;" class="MsoNormalTable" border="1" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 125.6pt; background-color: transparent;" valign="top" width="167"&gt;&lt;br&gt;&lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 229.5pt; background-color: transparent;" valign="top" width="306"&gt;&lt;b&gt;WMDM 11&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 247.5pt; background-color: transparent;" valign="top" width="330"&gt;&lt;b&gt;WPD&lt;/b&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 125.6pt; background-color: transparent;" valign="top" width="167"&gt;Operating Systems &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 229.5pt; background-color: transparent;" valign="top" width="330"&gt;Windows XP + Windows Media Format 11 Redistributable, Windows Vista &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 247.5pt; background-color: transparent;" valign="top" width="330"&gt;Windows XP + Windows Media Format 11 Redistributable, Windows Vista &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 125.6pt; background-color: transparent;" valign="top" width="167"&gt;Processors &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 229.5pt; background-color: transparent;" valign="top" width="306"&gt;X86, AMD64 (SysWOW mode only) &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 247.5pt; background-color: transparent;" valign="top" width="330"&gt;X86, AMD64 &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 125.6pt; background-color: transparent;" valign="top" width="167"&gt;SDKs&lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 229.5pt; background-color: transparent;" valign="top" width="306"&gt;Windows Media Format SDK 11 &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 247.5pt; background-color: transparent;" valign="top" width="330"&gt;Windows SDK &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;u&gt;Common Device-level Operations&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Both WPD and WMDM support basic device-level operations: enumeration of connected devices,&amp;nbsp;managing device-level properties, and querying of static device capabilities.&lt;/p&gt;
&lt;p&gt;WMDM's &lt;a href="http://msdn.microsoft.com/en-us/library/bb231801%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb231801(VS.85).aspx"&gt;IWMDMDeviceControl&lt;/a&gt; operations&amp;nbsp;internally delegate to the service provider (through &lt;a href="http://msdn.microsoft.com/en-us/library/bb231655%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb231655(VS.85).aspx"&gt;IMDSPDeviceControl&lt;/a&gt;), and would require the service provider to support these operations. While device playback control is not natively supported by the WPD API, WPD's extensibility mechanism makes it easy to add this as a custom command to your driver. For example, your WPD driver can support a custom Playback command that&amp;nbsp;your&amp;nbsp;application can invoke using &lt;a href="http://msdn.microsoft.com/en-us/library/dd375691%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd375691(VS.85).aspx"&gt;IPortableDevice::SendCommand&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="border: medium none ; border-collapse: collapse;" class="MsoNormalTable" border="1" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;&lt;b&gt;Operation&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;&lt;b&gt;Example WMDM API&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;&lt;b&gt;Suggested WPD API&lt;/b&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Enumerate attached devices &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDeviceManager2::EnumDevices2 &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceManager::GetDevices &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Enumerating device content &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMDevice::EnumStorage &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::EnumObjects &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Examine device capabilities &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMDevice::GetFormatSupport, IWMDMDevice2::GetFormatCapability &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceCapabilities:: GetSupportedContentTypes, GetSupportFormats &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;
&lt;p&gt;Retrieve device properties&lt;/p&gt;&lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMDevice::GetManufacturer &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceManager:: GetDeviceManufacturer&amp;nbsp;&lt;span style="font-size: 10pt; font-family: 'Arial','sans-serif';"&gt;OR &lt;br&gt;&lt;/span&gt;IPortableDeviceProperties::GetValues(WPD_DEVICE_OBJECT_ID) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Write device&amp;nbsp;properties &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMDevice3::SetProperty &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceProperties::SetValues(WPD_DEVICE_OBJECT_ID) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Controlling device playback &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMDeviceControl::Play &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="401"&gt;- &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;u&gt;Common Object-level Operations&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;A WPD object is analogous to a WMDM storage, and most WMDM storage operations have their equivalent WPD API.&amp;nbsp;&amp;nbsp; WPD is ObjectID-based, so each interface method that supports object-level operations receives&amp;nbsp;an Object Identifier&amp;nbsp;as a parameter.&amp;nbsp;&amp;nbsp; WMDM is interface-based, &lt;a href="http://msdn.microsoft.com/en-us/library/bb231928%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb231928(VS.85).aspx"&gt;IWMDMStorage&lt;/a&gt; represents a storage or a file, and&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/bb231909%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/bb231909(VS.85).aspx"&gt;IWMDMStorageControl&lt;/a&gt; implements the operations on a storage or a file.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For data object creation, both WPD and WMDM support transfer of protected Windows Media Digital Rights Management (WMDRM) content.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="border: medium none ; border-collapse: collapse;" class="MsoNormalTable" border="1" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;&lt;b&gt;Operation&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;&lt;b&gt;Example WMDM API&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;&lt;b&gt;Suggested WPD API&lt;/b&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Enumerating&amp;nbsp;objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMDevice::EnumStorage, IWMDMEnumStorage::Next &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::EnumObjects, IEnumPortableDeviceObjectIDs::Next &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Create a folder object &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorageControl::Insert3 &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::&amp;nbsp; CreateObjectWithPropertiesOnly &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Create a data object &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorageControl::Insert3 &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent:: CreateObjectWithPropertiesAndData &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Transfer object data from device &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorageControl::Read &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceResources::GetStream &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Move objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorageControl::Move &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::Move &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Copy objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::Copy &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Delete objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorageControl::Delete &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceContent::Delete &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Retrieve object properties &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorage4::GetSpecifiedMetadata &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceProperties::GetValues &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Write object properties &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;IWMDMStorage3::SetMetadata &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceProperties::SetValues &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Delete object properties &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="273"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceProperties::Delete &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;u&gt;Device Events&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;There are only 4&amp;nbsp;events that WMDM applications can receive: media arrival/removal, and device arrival/removal. WPD supports device-level and the more granular object-level events, plus built-in extensibility for &lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/03/16/how-to-post-events-from-your-wpd-driver.aspx" title="Custom WPD Events" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/03/16/how-to-post-events-from-your-wpd-driver.aspx"&gt;custom events&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="border: medium none ; border-collapse: collapse;" class="MsoNormalTable" border="1" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;&lt;b&gt;Operation&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;&lt;b&gt;Example WMDM API&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;&lt;b&gt;Suggested WPD API&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Monitor object-level property changes 
&lt;/td&gt;&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceEventCallback::OnEvent (WPD_EVENT_OBJECT_UPDATED) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Monitor object-level arrival and removal &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceEventCallback::OnEvent (WPD_EVENT_OBJECT_ADDED, WPD_EVENT_OBJECT_REMOVED) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Monitor media arrival and removal &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMNotification::WMDMMessage (WMDM_MSG_MEDIA_ARRIVAL, WMDM_MSG_MEDIA_REMOVAL) &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceEventCallback::OnEvent (WPD_EVENT_OBJECT_ADDED, WPD_EVENT_OBJECT_REMOVED) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Monitor device removal &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMNotification::WMDMMessage (WMDM_MSG_DEVICE_REMOVAL) &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;IPortableDeviceEventCallback::OnEvent (WPD_EVENT_DEVICE_REMOVED) &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;
&lt;p&gt;Monitor device arrival&lt;/p&gt;&lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.7pt; background-color: transparent;" valign="top" width="274"&gt;IWMDMNotification::WMDMMessage (WMDM_MSG_DEVICE_ARRIVAL) &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="401"&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/03/17/how-to-receive-wpd-device-arrival-events.aspx" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/03/17/how-to-receive-wpd-device-arrival-events.aspx"&gt;Subscribe&lt;/a&gt; to WPD interface arrival PnP event &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;u&gt;Advanced Operations&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Both WPD and WMDM provide some extensibility mechanism for sending device-specific commands.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;a href="http://msdn2.microsoft.com/en-us/library/bb231793.aspx" class="" title="IWMDMDevice3::DeviceIoControl" mce_href="http://msdn2.microsoft.com/en-us/library/bb231793.aspx"&gt;IWMDMDevice3::DeviceIoControl&lt;/a&gt; is used for&amp;nbsp;packaging and sending&amp;nbsp;commands only to Media Transfer Protocol&amp;nbsp;(MTP) portable media players.&lt;/p&gt;
&lt;p&gt;WPD API methods&amp;nbsp;that map to&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/aa528314.aspx" title="WPD Commands" mce_href="http://msdn.microsoft.com/en-us/library/aa528314.aspx"&gt;Command GUIDs&lt;/a&gt; internally delegate to &lt;a href="http://msdn.microsoft.com/en-us/library/dd375691%28VS.85%29.aspx" title="IPortableDevice::SendCommand" mce_href="http://msdn.microsoft.com/en-us/library/dd375691(VS.85).aspx"&gt;IPortableDevice::SendCommand&lt;/a&gt;.&amp;nbsp;&amp;nbsp;Applications&amp;nbsp;can&amp;nbsp;invoke these commands with additional options or parameters, such as the use of Read or Write&amp;nbsp;IOCTLs for access control.&lt;/p&gt;
&lt;p&gt;In addition, for better performance, WPD supports batching of property writes and retrievals across multiple objects, either per format or using a list of Object Identifiers.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table style="border: medium none ; border-collapse: collapse;" class="MsoNormalTable" border="1" cellpadding="0" cellspacing="0"&gt;
&lt;tbody&gt;
&lt;tr style=""&gt;
&lt;td style="border: 1pt solid black; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;&lt;b&gt;Operation&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 200.55pt; background-color: transparent;" valign="top" width="267"&gt;&lt;b&gt;Example WMDM API&lt;/b&gt; &lt;/td&gt;
&lt;td style="border-style: solid solid solid none; border-color: black black black rgb(240, 240, 240); border-width: 1pt 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="407"&gt;&lt;b&gt;Suggested WPD API&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Retrieve properties of multiple objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 200.55pt; background-color: transparent;" valign="top" width="267"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="407"&gt;IPortableDevicePropertiesBulk::&amp;nbsp; QueueGetValuesByObjectList, OR QueueGetValuesByObjectFormat &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="407"&gt;Set properties of multiple objects &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 200.55pt; background-color: transparent;" valign="top" width="267"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="407"&gt;IPortableDevicePropertiesBulk:: QueueSetValuesByObjectList &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Send device-specific commands &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 200.55pt; background-color: transparent;" valign="top" width="267"&gt;IWMDMDevice::SendOpaqueCommand OR IWMDMDevice3::DeviceIoControl &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="407"&gt;IPortableDevice::SendCommand &lt;/td&gt;&lt;/tr&gt;
&lt;tr style=""&gt;
&lt;td style="border-style: none solid solid; border-color: rgb(240, 240, 240) black black; border-width: medium 1pt 1pt; padding: 0in 5.4pt; width: 95.4pt; background-color: transparent;" valign="top" width="127"&gt;Cancel an operation &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 200.55pt; background-color: transparent;" valign="top" width="267"&gt;- &lt;/td&gt;
&lt;td style="border-style: none solid solid none; border-color: rgb(240, 240, 240) black black rgb(240, 240, 240); border-width: medium 1pt 1pt medium; padding: 0in 5.4pt; width: 205.05pt; background-color: transparent;" valign="top" width="407"&gt;IPortableDevice*::Cancel, e.g. IPortableDeviceProperties::Cancel &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;&lt;u&gt;Stability&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;WMDM loads registered service providers (SPs) within the same process as the application. Any crash or instability in the device driver or SP could cause undue crashes in the application process, or worse, trigger bluescreens if kernel mode drivers are involved.&lt;/p&gt;
&lt;p&gt;WPD drivers are sandboxed in the User Mode Driver Framework (UMDF) host process, and gain the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa511005.aspx" title="UMDF Stability and Security" mce_href="http://msdn2.microsoft.com/en-us/library/aa511005.aspx"&gt;stability and security benefits&lt;/a&gt; of a UMDF driver. If a WPD driver crashes, only the sandbox process will be affected; the WPD application process is isolated from the driver instability. In a similar way, a WPD driver's process&amp;nbsp;is not affected when a WPD client application crashes.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;&lt;u&gt;The Verdict&lt;/u&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;WPD and WMDM have a lot of overlap in&amp;nbsp;terms of the&amp;nbsp;device operations that each enables.&amp;nbsp;&amp;nbsp; WMDM is geared&amp;nbsp;specifically towards portable media player applications and scenarios,&amp;nbsp;with media-centric metadata schema, support for device playback control, and direct access to Windows Media Digital Rights Management (WMDRM)&amp;nbsp;application interfaces.&amp;nbsp;&amp;nbsp;&amp;nbsp;WPD supports much of what WMDM does (including WMDRM transfers), &lt;i&gt;plus &lt;/i&gt;many key advantages over WMDM, including&amp;nbsp;stability, UMDF integration,&amp;nbsp;comprehensive property and content type&amp;nbsp;schema (beyond portable media devices),&amp;nbsp;extensibility for custom device solutions, broader device support,&amp;nbsp;and&amp;nbsp;not to mention, great &lt;a href="http://msdn2.microsoft.com/en-us/library/aa973613.aspx" class="" title="WpdInfo" mce_href="http://msdn2.microsoft.com/en-us/library/aa973613.aspx"&gt;development tools&lt;/a&gt;.&lt;/p&gt;
&lt;p mce_keep="true"&gt;For applications that&amp;nbsp;would&amp;nbsp;like to&amp;nbsp;connect to, control,&amp;nbsp;and manage content&amp;nbsp;across a &lt;i&gt;wide range of devices&lt;/i&gt; (digital still cameras, portable media players, cellular phones, third-party device classes,&amp;nbsp;and more), WPD is the clear choice.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: normal;"&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: 'Arial','sans-serif';"&gt;&lt;/span&gt;&lt;/i&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 10pt; line-height: normal;"&gt;&lt;i&gt;&lt;span style="font-size: 10pt; font-family: 'Arial','sans-serif';"&gt;This posting is provided "AS IS" with no warranties and confers no rights.&lt;/span&gt;&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1943316" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WMDM/default.aspx">WMDM</category></item><item><title>How to Receive WPD Arrival Event Notifications</title><link>http://blogs.msdn.com/wpdblog/archive/2007/03/17/how-to-receive-wpd-device-arrival-events.aspx</link><pubDate>Sat, 17 Mar 2007 04:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1897354</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1897354.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1897354</wfw:commentRss><description>&lt;p&gt;If you&amp;nbsp;followed the &lt;a href="http://msdn.microsoft.com/en-us/library/aa528331.aspx" title="WPD Event Constants" mce_href="http://msdn.microsoft.com/en-us/library/aa528331.aspx"&gt;standard WPD events&lt;/a&gt;&amp;nbsp;link in our &lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/03/16/how-to-post-events-from-your-wpd-driver.aspx" class="" title="Posting WPD Driver Events" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/03/16/how-to-post-events-from-your-wpd-driver.aspx"&gt;previous post&lt;/a&gt;&amp;nbsp;on WPD driver events, you&amp;nbsp;may have seen&amp;nbsp;the following&amp;nbsp;event&amp;nbsp;definition:&lt;/p&gt;
&lt;table style="width: 645px; height: 121px;" border="0" cols="2" frame="below" rules="rows"&gt;
&lt;tbody&gt;
&lt;tr valign="top"&gt;
&lt;td width="45%"&gt;WPD_EVENT_DEVICE_REMOVED&lt;/td&gt;
&lt;td width="55%"&gt;This event is sent when a driver for a device is being unloaded. This is typically a result of the device being unplugged. 
&lt;p&gt;Clients should release the &lt;b&gt;IPortableDevice&lt;/b&gt; interface they have open on the device specified in WPD_EVENT_PARAMETER_PNP_DEVICE_ID.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;In a nutshell, when a WPD device disconnects,&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/dd388546%28VS.85%29.aspx" title="IPortableDeviceEventCallback::OnEvent" mce_href="http://msdn.microsoft.com/en-us/library/dd388546(VS.85).aspx"&gt;IPortableDeviceEventCallback::OnEvent&lt;/a&gt;&amp;nbsp;is called with this specific event GUID and the PnP Device ID&amp;nbsp;in the event parameters, allowing applications to&amp;nbsp;clean up the associated WPD interfaces for that device instance, display UI, etc.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;Having an event to tell an application when a device is disconnected can help&amp;nbsp;applications build richer or smarter&amp;nbsp;device scenarios.&amp;nbsp; &amp;nbsp; &lt;b&gt;Why isn't there a device&amp;nbsp;arrival&amp;nbsp;event,&amp;nbsp;ala&amp;nbsp;WPD_EVENT_DEVICE_&lt;i&gt;ARRIVED&lt;/i&gt;, to cover the converse Disconnected -&amp;gt; Connected case?&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The reason this hypothetical event doesn't exist is that WPD events utilize the&amp;nbsp;&lt;a href="http://msdn2.microsoft.com/en-us/library/aa511339.aspx" class="" title="IWDFDevice::PostEvent" mce_href="http://msdn2.microsoft.com/en-us/library/aa511339.aspx"&gt;IWDFDevice::PostEvent&lt;/a&gt; mechanism, which requires the WPD driver to up and running (with the device connected).&amp;nbsp;&amp;nbsp;&amp;nbsp; Consequently, to receive such events, a WPD application has to invoke IPortableDevice::Advise and maintain an open IPortableDevice connection.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;Device Interface&amp;nbsp;Arrival Events to the Rescue&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;Fortunately, Plug-and-Play&amp;nbsp;provides your application with the ability to receive broadcast device notifications on device interfaces, including WPD's.&amp;nbsp; This standard mechanism has existed long before WPD, and is documented &lt;a href="http://msdn2.microsoft.com/en-us/library/aa363432.aspx" class="" title="Registering for Device Notification" mce_href="http://msdn2.microsoft.com/en-us/library/aa363432.aspx"&gt;here&lt;/a&gt;&amp;nbsp;in MSDN.&amp;nbsp;&amp;nbsp; The following code snippets show how to register for WPD device interface notifications, and how to handle the corresponding arrival event.&lt;/p&gt;&lt;span style="font-size: 9pt; font-family: 'courier-new';"&gt;&lt;pre&gt;//&lt;br&gt;// Step 1: Registering for WPD device interface PnP notification events&lt;br&gt;//&lt;br&gt;&lt;br&gt;// The WPD device interface GUID&lt;br&gt;#define WPD_DEVINTERFACE L"{6ac27878-a6fa-4155-ba85-f98f491d4f33}"&lt;br&gt;&lt;br&gt;GUID guidDevInterface            = GUID_NULL;&lt;br&gt;DEV_BROADCAST_DEVICEINTERFACE db = {0};&lt;br&gt;db.dbcc_size = sizeof(db);&lt;br&gt;db.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;&lt;br&gt;CLSIDFromString(WPD_DEVINTERFACE, &amp;amp;guidDevInterface);&lt;br&gt;db.dbcc_classguid  = guidDevInterface;&lt;br&gt;&lt;br&gt;hDevNotify = RegisterDeviceNotificationW(hWnd, &amp;amp;db, DEVICE_NOTIFY_WINDOW_HANDLE);&lt;br&gt;&lt;br&gt;do error checking ...&lt;br&gt;&lt;br&gt;&lt;br&gt;//&lt;br&gt;// Step 2: Processing the DBT_DEVICEARRIVAL event when a WPD device is connected&lt;br&gt;//&lt;br&gt;&lt;br&gt;LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)&lt;br&gt;{  &lt;br&gt;   switch (uMsg)&lt;br&gt;   {&lt;br&gt;       ....&lt;br&gt;&lt;br&gt;       case WM_DEVICECHANGE:&lt;br&gt;       {&lt;br&gt;          switch(wParam) &lt;br&gt;          {	    &lt;br&gt;             case DBT_DEVICEARRIVAL:&lt;br&gt;             {&lt;br&gt;                 PDEV_BROADCAST_HDR pdbh = (PDEV_BROADCAST_HDR)lParam;&lt;br&gt;                 if (pdbh != NULL &amp;amp;&amp;amp; pdbh-&amp;gt;dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)&lt;br&gt;                 {&lt;br&gt;                     PDEV_BROADCAST_DEVICEINTERFACE pdbi = (PDEV_BROADCAST_DEVICEINTERFACE)lParam;&lt;br&gt;            &lt;br&gt;                     if (IsEqualGUID(pdbi-&amp;gt;dbcc_classguid, guidDevInterface)) &lt;br&gt;                     {&lt;br&gt;                         // Initialization is skipped here for brevity&lt;br&gt;                         // Use the symbolic name to open a PortableDevice connection&lt;br&gt;                         // pClientInfo is an IPortableDeviceValues containing the client information&lt;br&gt;                         // NOTE: Use a separate thread if your code could block&lt;br&gt;                         hr = pIPortableDevice-&amp;gt;Open(pdbi-&amp;gt;dbcc_name, pClientInfo);&lt;br&gt;&lt;br&gt;                         do more error checking ...&lt;br&gt;                     }&lt;br&gt;		 }&lt;br&gt;                 break;         &lt;br&gt;             }&lt;br&gt;             &lt;br&gt;             ...&lt;br&gt; &lt;br&gt;          } // switch (wParam)&lt;br&gt;       }&lt;br&gt;       break;&lt;br&gt;       ....&lt;br&gt;   } // switch (uMsg)&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;&lt;/span&gt;
&lt;p mce_keep="true"&gt;To summarize, the application will receive a &lt;a onclick="javascript:Track('ctl00_LibFrame_ctl01|ctl00_LibFrame_ctl04',this);" href="http://msdn2.microsoft.com/en-us/library/aa363480.aspx"&gt;WM_DEVICECHANGE&lt;/a&gt; message for the &lt;a onclick="javascript:Track('ctl00_LibFrame_ctl01|ctl00_LibFrame_ctl05',this);" href="http://msdn2.microsoft.com/en-us/library/aa363205.aspx"&gt;DBT_DEVICEARRIVAL&lt;/a&gt;&amp;nbsp;event when the device is connected.&amp;nbsp;&amp;nbsp; DEV_BROADCAST_DEVICEINTERFACE.dbcc_name is equivalent to the WPD PnP Device ID, which the application can use when calling IPortableDevice::Open.&lt;/p&gt;
&lt;p mce_keep="true"&gt;The &lt;a href="http://msdn2.microsoft.com/en-us/library/aa363431.aspx" class="" title="RegisterDeviceNotification" mce_href="http://msdn2.microsoft.com/en-us/library/aa363431.aspx"&gt;guidelines&lt;/a&gt; for processing Plug-and-Play messages apply: the event handler should process the event as quickly as possible, using a separate thread if there's a possibility of blocking execution, to avoid undue system hangs.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;Choices of Device Removal Events&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;The application will also receive a DBT_DEVICEREMOVECOMPLETE&amp;nbsp;event, which can&amp;nbsp;be useful for&amp;nbsp;e.g. placing arrival and removal handlers in the same code module.&amp;nbsp;&amp;nbsp; The difference between&amp;nbsp;this&amp;nbsp;event&amp;nbsp;and WPD_EVENT_DEVICE_REMOVED is subtle.&amp;nbsp;&amp;nbsp; The latter&amp;nbsp;is&amp;nbsp;a custom PnP event that&amp;nbsp;is sent via WUDF&amp;nbsp;during&amp;nbsp;&lt;i&gt;unloading of&amp;nbsp;the WPD&amp;nbsp;driver &lt;/i&gt;(usually caused by&amp;nbsp;a device unplug); whereas DBT_DEVICEREMOVECOMPLETE is triggered&amp;nbsp;by the &lt;i&gt;removal of&amp;nbsp;a&amp;nbsp;device interface&lt;/i&gt; (also caused by&amp;nbsp;a device unplug).&amp;nbsp;&amp;nbsp; Usually, WPD&amp;nbsp;applications that just&amp;nbsp;want&amp;nbsp;a notification when&amp;nbsp;WPD devices are disconnected&amp;nbsp;can subscribe to either&amp;nbsp;event and get the same effect.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;Further Reading (and more code samples)&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;To learn more&amp;nbsp;on how to use&amp;nbsp;PnP device&amp;nbsp;notifications, refer to this detailed &lt;a href="http://www.codeproject.com/useritems/HwDetect.asp" class="" title="Detecting H/W Insertion or Removal - The Code Project" mce_href="http://www.codeproject.com/useritems/HwDetect.asp"&gt;article&lt;/a&gt; from The Code Project.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;&lt;/i&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1897354" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/PnP/default.aspx">PnP</category></item><item><title>Getting ERROR_BUSY (0x800700AA) after reading data from an MTP device?</title><link>http://blogs.msdn.com/wpdblog/archive/2007/03/09/getting-error-busy-0x800700aa-after-reading-data-from-an-mtp-device.aspx</link><pubDate>Fri, 09 Mar 2007 22:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1847534</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1847534.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1847534</wfw:commentRss><description>&lt;P&gt;One common cause of the ERROR_BUSY (0x800700AA) in MTP devices is when the application&amp;nbsp;reads resource data from&amp;nbsp;a content object on the portable device using IStream::Read(), and does not complete the read&amp;nbsp;with an IStream::Close().&amp;nbsp;&amp;nbsp;&amp;nbsp;Subsequent operations&amp;nbsp;that eventually translate into MTP&amp;nbsp;commands into the device could fail&amp;nbsp;with ERROR_BUSY because the resource read operation is not yet complete.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sometimes the failure could&amp;nbsp;appear delayed -&amp;nbsp;&amp;nbsp;after the resource read, there could be&amp;nbsp;several successful&amp;nbsp;WPD API calls before ERROR_BUSY appears, because the interim calls that succeeded were handled by the MTP driver (i.e. do not require the driver to talk to the device).&lt;/P&gt;
&lt;P&gt;From the device's perspective,&amp;nbsp;reading resource data translates to a sequence of operations involving the MTP command "GetObject".&amp;nbsp;&amp;nbsp;&amp;nbsp; This has to be&amp;nbsp;completed&amp;nbsp;or cancelled before&amp;nbsp;further&amp;nbsp;MTP commands to the device could proceed.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;For example, if your application does the following:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'courier-new'"&gt;
IStream* pObjectDataStream = NULL;

// 1. Open the default resource of an object with read access
HRESULT hr = pIPortableDeviceResources-&amp;gt;GetStream(wszObjectID, 
                                                     WPD_RESOURCE_DEFAULT, 
                                                     STGM_READ, 
                                                     &amp;amp;cbOptimalTransferSize,
                                                     &amp;amp;pObjectDataStream);

// 2. Read some data from the resource stream created by GetStream
if (hr == S_OK)
{
  hr = pObjectDataStream-&amp;gt;Read(pObjectData, cbOptimalTransferSize, &amp;amp;cbBytesRead);
}

// 3. Do other operations that translate into MTP commands to the device
// and they could result in 0x800700AA as the resource read operation is not complete&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;To fix this, ensure that IStream::Release() is called to complete or cancel the current read operation before proceeding &lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'courier-new'"&gt;
IStream* pObjectDataStream = NULL;

// 1. Open the default resource of an object with read access
HRESULT hr = pIPortableDeviceResources-&amp;gt;GetStream(wszObjectID, 
                                                     WPD_RESOURCE_DEFAULT, 
                                                     STGM_READ, 
                                                     &amp;amp;cbOptimalTransferSize,
                                                     &amp;amp;pObjectDataStream);

// 2. Read some data from the resource stream created by GetStream
if (hr == S_OK)
{
  hr = pObjectDataStream-&amp;gt;Read(pObjectData, cbOptimalTransferSize, &amp;amp;cbBytesRead);
}

// 3. IMPORTANT: Release the IStream if no longer using it to ensure that the read operation
// completes.   &lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'courier-new'"&gt;
if(pObjectDataStream)
{
    pObjectDataStream-&amp;gt;Release();  // If using a CComPtr, set it to NULL
}

// 4. Proceed on to the other operations
&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;If your application is reading resource data from&amp;nbsp;an MTP device, and you are seeing ERROR_BUSY, check that you are always&amp;nbsp;calling Release()&amp;nbsp;on the IStream objects that you have opened.&amp;nbsp;&amp;nbsp;&amp;nbsp; This also applies if you are using smart pointers (e.g. CComPtr&amp;lt;IStream&amp;gt;), in which&amp;nbsp;case you can explicitly set the pointer to NULL&amp;nbsp;to tell the smart pointer to&amp;nbsp;Release() itself before&amp;nbsp;you proceed on to other&amp;nbsp;device operations.&amp;nbsp;&amp;nbsp;&amp;nbsp;This will release the pointer&amp;nbsp;after&amp;nbsp;you&amp;nbsp;have completed your&amp;nbsp;resource read/write operation(s),&amp;nbsp;instead of&amp;nbsp;relying on the IStream smart pointer to get out of scope.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Similarly, if your application is writing resource data to an MTP device, ensure that you're calling IStream::Commit() or IStream::Revert() to complete the write operation.&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;STRONG&gt;[June 11, 2007]&amp;nbsp;&lt;/STRONG&gt;Thanks to drlily for pointing out&amp;nbsp;that IStream::Close does not actually exist.&amp;nbsp;&amp;nbsp;It should have been&amp;nbsp;IStream::Release&amp;nbsp;for a read IStream, and IStream::Commit, IStream::Revert, or IStream::Release for a write IStream.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/EM&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1847534" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/MTP/default.aspx">MTP</category></item><item><title>Object Creation: Required Properties and Debugging Failures</title><link>http://blogs.msdn.com/wpdblog/archive/2007/03/02/object-creation-required-properties-and-debugging-failures.aspx</link><pubDate>Fri, 02 Mar 2007 21:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1789555</guid><dc:creator>wpdblog</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1789555.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1789555</wfw:commentRss><description>&lt;p mce_keep="true"&gt;&lt;b&gt;Basic Set of Properties for Folder Creation&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;When creating a folder object, the following properties are required when calling &lt;a href="http://msdn.microsoft.com/en-us/library/dd388535%28VS.85%29.aspx" title="CreateObjectWithPropertiesOnly" mce_href="http://msdn.microsoft.com/en-us/library/dd388535(VS.85).aspx"&gt;IPortableDeviceContent::CreateObjectWithPropertiesOnly&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;WPD_OBJECT_PARENT_ID:&amp;nbsp; VT_LPWSTR, Parent Object ID&lt;/li&gt;
&lt;li&gt;WPD_OBJECT_NAME:&amp;nbsp;VT_LPWSTR, Name of the new object &lt;/li&gt;
&lt;li&gt;WPD_OBJECT_CONTENT_TYPE =&amp;nbsp;WPD_CONTENT_TYPE_FOLDER&lt;/li&gt;
&lt;li&gt;WPD_OBJECT_FORMAT = WPD_OBJECT_FORMAT_PROPERTIES_ONLY&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Some devices (such as the Toshiba MES30VW Gigabeat) require&amp;nbsp;the following additional property when creating a folder object, or&amp;nbsp;the&amp;nbsp;object creation would fail with 0x80040000. &amp;nbsp; &lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;WPD_OBJECT_ORIGINAL_FILE_NAME: VT_LPWSTR, Original file name of the new object&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Typically, the&amp;nbsp;original file name property&amp;nbsp;can be set to the same value&amp;nbsp;for&amp;nbsp;WPD_OBJECT_NAME.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Basic Set of Properties for&amp;nbsp;Creating Other&amp;nbsp;Objects&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;For&lt;b&gt;&amp;nbsp;&lt;/b&gt;creating other objects, the &lt;a href="http://msdn.microsoft.com/en-us/library/dd375715%28VS.85%29.aspx" title="Requirements for Objects" mce_href="http://msdn.microsoft.com/en-us/library/dd375715(VS.85).aspx"&gt;set of required properties&lt;/a&gt; will vary depending on the Content Type of the object.&amp;nbsp;&amp;nbsp; For creating objects with data (such as a Music or an Image file), use &lt;a href="http://msdn.microsoft.com/en-us/library/dd388534%28VS.85%29.aspx" title="CreateObjectWithPropertiesAndData" mce_href="http://msdn.microsoft.com/en-us/library/dd388534(VS.85).aspx"&gt;IPortableDeviceContent::CreateObjectsWithPropertiesAndData&lt;/a&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Debugging Object Creation Failures (and Others)&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;You can run WpdMon to&amp;nbsp;view&amp;nbsp;the traffic between the application and the responses from the device.&amp;nbsp;&amp;nbsp;&amp;nbsp;This helps&amp;nbsp;to&amp;nbsp;zero&amp;nbsp;in on the errors&amp;nbsp;and responses from the driver&amp;nbsp;before&amp;nbsp;the error codes are bubbled up to the application level.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The following capture shows an attempted folder creation&amp;nbsp;on an MTP&amp;nbsp;device (the Creative Zen Vision M)&amp;nbsp;using&amp;nbsp;the WPD Shell Namespace Extension (i.e. Explorer).&amp;nbsp;&amp;nbsp; IPortableDeviceContent::CreateObjectWithPropertiesOnly corresponds to the&amp;nbsp;WPD driver command&amp;nbsp;WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY&lt;i&gt;.&amp;nbsp;&amp;nbsp; &lt;/i&gt;&lt;/p&gt;
&lt;p&gt;Date Created and Date Modified are both additional optional properties that the&amp;nbsp;WPD Shell Namespace chooses to specify when creating folder objects.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;The client information context is&amp;nbsp;a string&amp;nbsp;identifier&amp;nbsp;that is added automatically by the WPD API in the command parameters.&amp;nbsp;&amp;nbsp; This is generated internally by the WPD API during &lt;i&gt;IPortableDevice::Open&lt;/i&gt;, and uniquely identifies the IPortableDevice instance. &lt;/p&gt;
&lt;p&gt;&lt;font face="Lucida Console" size="1"&gt;&lt;b&gt;&lt;/b&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font face="Lucida Console" size="1"&gt;&lt;b&gt;Timestamp:&lt;/b&gt; 03/02/2007 10:48:25.0806&lt;br&gt;&lt;b&gt;Operation:&lt;/b&gt; &lt;font color="#0000dd"&gt;(Request) &lt;b&gt;WPD_COMMAND_OBJECT_MANAGEMENT_CREATE_OBJECT_WITH_PROPERTIES_ONLY&lt;/b&gt; from Application (&lt;b&gt;4 elements&lt;/b&gt;)&lt;/font&gt;&lt;br&gt;WPD_PROPERTY_COMMON_COMMAND_CATEGORY&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_CLSID&amp;nbsp;&amp;nbsp; ] &lt;b&gt;WPD_CATEGORY_OBJECT_MANAGEMENT&lt;/b&gt;&lt;br&gt;WPD_PROPERTY_COMMON_COMMAND_ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_UI4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ] &lt;b&gt;0x2&lt;/b&gt; (Decimal: &lt;b&gt;2&lt;/b&gt;) WPD_PROPERTY_OBJECT_MANAGEMENT_CREATION_PROPERTIES = [VT_UNKNOWN ] &lt;b&gt;IPortableDeviceValues (7 elements)&lt;/b&gt;&lt;br&gt;WPD_OBJECT_PARENT_ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_LPWSTR&amp;nbsp; ] &lt;b&gt;s10001&lt;/b&gt;&lt;br&gt;WPD_OBJECT_ORIGINAL_FILE_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_LPWSTR&amp;nbsp; ] &lt;b&gt;New Folder&lt;/b&gt;&lt;br&gt;WPD_OBJECT_NAME&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_LPWSTR&amp;nbsp; ] &lt;b&gt;New Folder&lt;/b&gt;&lt;br&gt;WPD_OBJECT_DATE_CREATED&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_DATE&amp;nbsp;&amp;nbsp;&amp;nbsp; ] &lt;b&gt;2007/3/2 10:48:25.0&lt;/b&gt;&lt;br&gt;WPD_OBJECT_DATE_MODIFIED&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_DATE&amp;nbsp;&amp;nbsp;&amp;nbsp; ] &lt;b&gt;2007/3/2 10:48:25.0&lt;/b&gt;&lt;br&gt;WPD_OBJECT_CONTENT_TYPE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_CLSID&amp;nbsp;&amp;nbsp; ] &lt;b&gt;WPD_CONTENT_TYPE_FOLDER&lt;/b&gt;&lt;br&gt;WPD_OBJECT_FORMAT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_CLSID&amp;nbsp;&amp;nbsp; ] &lt;b&gt;WPD_OBJECT_FORMAT_PROPERTIES_ONLY&lt;/b&gt;&lt;br&gt;WPD_PROPERTY_COMMON_CLIENT_INFORMATION_CONTEXT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_LPWSTR&amp;nbsp; ] &lt;b&gt;{F86BC3B3-D205-463F-80CF-DB43C51D4FE2}&lt;/b&gt;&lt;br&gt;&lt;br&gt;&lt;b&gt;Timestamp:&lt;/b&gt; 03/02/2007 10:48:25.0806&lt;br&gt;&lt;b&gt;Operation:&lt;/b&gt; &lt;font color="#008000"&gt;(Response) IPortableDeviceValues from Driver (&lt;b&gt;1 elements&lt;/b&gt;)&lt;/font&gt;&lt;br&gt;WPD_PROPERTY_COMMON_HRESULT&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = [VT_ERROR&amp;nbsp;&amp;nbsp; ] &lt;b&gt;0x800700AA&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;Even though the application has provided all the required property values&amp;nbsp;(and then some), the WPD driver&amp;nbsp;still failed the command with 0x800700AA (ERROR_BUSY).&amp;nbsp; This means that the driver is busy servicing other requests, and the application should try the request&amp;nbsp;again later.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;By&amp;nbsp;using WpdMon, we are able to determine that the failure in CreateObjectWithPropertiesOnly had originated from the driver or the device.&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;This &lt;a href="http://blogs.msdn.com/dimeby8/archive/2006/11/08/help-wpd-api-calls-randomly-fail-with-0x800700aa-error-busy.aspx" class="" title="DimeBy8" mce_href="http://blogs.msdn.com/dimeby8/archive/2006/11/08/help-wpd-api-calls-randomly-fail-with-0x800700aa-error-busy.aspx"&gt;post&lt;/a&gt; provides more details on ERROR_BUSY.&lt;/p&gt;
&lt;p mce_keep="true"&gt;The same technique of viewing WpdMon traffic can be applied to diagnosing&amp;nbsp;error responses returned from&amp;nbsp;other methods in the&amp;nbsp;WPD API to determine which level the error appeared (the application, the WPD API, or the driver/device).&amp;nbsp;&amp;nbsp; The trick is to map the WPD API call to the &lt;a href="http://msdn.microsoft.com/en-us/library/dd319301%28VS.85%29.aspx" title="WPD Commands" mce_href="http://msdn.microsoft.com/en-us/library/dd319301(VS.85).aspx"&gt;driver command&lt;/a&gt;.&amp;nbsp;&amp;nbsp; It is a straightforward mapping, for example:&lt;/p&gt;
&lt;p mce_keep="true"&gt;IPortableDeviceProperties::GetValues =&amp;gt;&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/aa528602.aspx" title="WPD_COMMAND_OBJECT_PROPERTIES_GET" mce_href="http://msdn.microsoft.com/en-us/library/aa528602.aspx"&gt;WPD_COMMAND_OBJECT_PROPERTIES_GET&lt;/a&gt; &lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;a href="http://blogs.msdn.com/wpdblog/archive/2007/02/05/wpdmon-gotchas.aspx" class="" title="WpdMon tips and tricks" mce_href="http://blogs.msdn.com/wpdblog/archive/2007/02/05/wpdmon-gotchas.aspx"&gt;More tips and tricks&lt;/a&gt; for using WpdMon.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1789555" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category></item><item><title>Enabling Your WPD application for AutoPlay on Windows Vista</title><link>http://blogs.msdn.com/wpdblog/archive/2007/02/23/enabling-your-wpd-application-for-autoplay-on-windows-vista.aspx</link><pubDate>Fri, 23 Feb 2007 05:40:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1744998</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1744998.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1744998</wfw:commentRss><description>&lt;p&gt;The power of WPD derives from built-in extensibility mechanisms and scenarios around content type and device function.&amp;nbsp; A good example is AutoPlay, which has been updated in Windows Vista to support WPD scenarios.&amp;nbsp;&amp;nbsp; 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.&amp;nbsp;&amp;nbsp; Application handlers can register for each type of content and function category that they are interested in.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Overview of the WPD AutoPlay Registration Scheme&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The WPD AutoPlay&amp;nbsp;scheme is defined as follows:&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;Source&lt;/i&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The list of content types in this group indicates what the device can provide.&lt;/li&gt;
&lt;li&gt;This allows for applications that are interested in browsing or acquiring device contents to be registered for devices that can provide that content.&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;Sink&lt;/i&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The list of content types in this group indicates what the device can accept.&lt;/li&gt;
&lt;li&gt;This allows for applications that are interested in putting content on the device to be registered for devices that can receive that content.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;&lt;i&gt;Function&lt;/i&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The list of categories in this group indicates what functions the device supports.&lt;/li&gt;
&lt;li&gt;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.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Note that this scheme is not limited to the content the device currently has on its storage, but rather, &lt;b&gt;what the device is capable of storing/doing&lt;/b&gt;.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;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.&amp;nbsp;&amp;nbsp;&amp;nbsp; 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.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;b&gt;Registering Your WPD Application for AutoPlay&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;To register for WPD AutoPlay events, applications need to add themselves to the appropriate WPD entry under the AutoPlayHandlers\EventHandlers key.&amp;nbsp; 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.&amp;nbsp;&amp;nbsp; You could register your application handler like this:&lt;/p&gt;
&lt;p&gt;&lt;br&gt;[HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers\EventHandlers\Wpd]:&lt;/p&gt;
&lt;p&gt;Sink &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {4AD2C85E-5E2D-45E5-8864-4F229E3C6CF0} &lt;i&gt;-&amp;gt; WPD_CONTENT_TYPE_AUDIO&lt;/i&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWpdSendMusicHandler, REG_SZ, (Empty) &lt;/p&gt;
&lt;p&gt;Source &lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {4AD2C85E-5E2D-45E5-8864-4F229E3C6CF0} &lt;i&gt;-&amp;gt; WPD_CONTENT_TYPE_AUDIO &lt;/i&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWpdAcquirePhotoMusicHandler, REG_SZ, (Empty) &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {EF2107D5-A52A-4243-A26B-62D4176D7603} &lt;i&gt;-&amp;gt; WPD_CONTENT_TYPE_IMAGE &lt;/i&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyWpdAcquirePhotoMusicHandler, REG_SZ, (Empty) &lt;/p&gt;
&lt;p&gt;&lt;br&gt;Both [MyWpdAcquirePhotoMusicHandler] and [MyWpdSendMusicHandler] are normal Autoplay registrations in HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers\Handlers.&amp;nbsp;&amp;nbsp; For more details, refer to this &lt;a href="http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/" class="" title="Autoplay in Windows XP" mce_href="http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/"&gt;MSDN article&lt;/a&gt; (suggested section: Autoplay V2 Registration Mechanism). &lt;/p&gt;
&lt;p&gt;The "EventHandlers\Wpd\..."&amp;nbsp;entries are defined using the content type and functional category &lt;b&gt;GUIDs&lt;/b&gt; (e.g. {EF2107D5-A52A-4243-A26B-62D4176D7603}), &lt;b&gt;not the symbolic names &lt;/b&gt;(i.e. WPD_CONTENT_TYPE_IMAGE).&amp;nbsp;&amp;nbsp; This is designed to support extensibility for custom content types and functional categories that devices and applications can register.&amp;nbsp; Published WPD GUID values and their associated symbolic names are defined in &lt;b&gt;PortableDevice.h&lt;/b&gt;, available in the Windows SDK.&lt;/p&gt;
&lt;p&gt;"Source" and "Sink" are content transfers &lt;b&gt;relative to the device, not the application&lt;/b&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp; In the example above, your application is registering for AutoPlay events for a WPD device that can do &lt;b&gt;one or more&lt;/b&gt; of the following: &lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Receive music content from your application&lt;/li&gt;
&lt;li&gt;Provide image or audio content to your application&amp;nbsp; &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;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}.&amp;nbsp;&amp;nbsp; Note that this will also register your application to handle devices that support custom content types.&lt;br&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;AutoPlay for Functional Category&amp;nbsp;&lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;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.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;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&amp;nbsp;in the&amp;nbsp;AutoPlay dialog:&lt;/p&gt;
&lt;p&gt;[HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoPlayHandlers\EventHandlers\Wpd]:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Function&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {613CA327-AB93-4900-B4FA-895BB5874B79}&amp;nbsp;&amp;nbsp;-&amp;gt; &lt;i&gt;WPD_FUNCTIONAL_CATEGORY_STILL_IMAGE_CAPTURE&lt;/i&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MyWpdImageCaptureHandler, REG_SZ, (Empty)&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;b&gt;Can I register AutoPlay for other device events? &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;AutoPlay only supports registration for device arrival events.&amp;nbsp;&amp;nbsp; Your application can still receive WPD events and custom events using &lt;a href="http://msdn.microsoft.com/en-us/library/dd375684%28VS.85%29.aspx" title="IPortableDevice::Advise" mce_href="http://msdn.microsoft.com/en-us/library/dd375684(VS.85).aspx"&gt;IPortableDevice::Advise&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;b&gt;What about Windows XP? &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The granular WPD Source/Sink/Function AutoPlay registration functionality is only available on Windows Vista.&amp;nbsp;&amp;nbsp; On Windows XP, the AutoPlay registration mechanisms are documented in this &lt;a href="http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/" class="" title="Autoplay in Windows XP" mce_href="http://msdn.microsoft.com/msdnmag/issues/01/11/autoplay/"&gt;MSDN article&lt;/a&gt; and in the MSDN library.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1744998" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/Autoplay/default.aspx">Autoplay</category></item><item><title>Working with WMDRM Protected Content using WPD</title><link>http://blogs.msdn.com/wpdblog/archive/2007/02/09/working-with-wmdrm-protected-content-using-wpd.aspx</link><pubDate>Sat, 10 Feb 2007 02:55:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1638560</guid><dc:creator>wpdblog</dc:creator><slash:comments>11</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1638560.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1638560</wfw:commentRss><description>&lt;p&gt;&lt;b&gt;Setting up your WPD&amp;nbsp;application to handle protected&amp;nbsp;WMDRM content&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;The WPD API supports the transfer and licensing&amp;nbsp;operations for &lt;a href="http://www.microsoft.com/windows/windowsmedia/forpros/drm/default.mspx" class="" title="WMDRM" mce_href="http://www.microsoft.com/windows/windowsmedia/forpros/drm/default.mspx"&gt;Windows Media Digital Rights Management&lt;/a&gt; (WMDRM) content.&lt;/p&gt;
&lt;p&gt;This &lt;a href="http://msdn.microsoft.com/en-us/library/dd375717%28VS.85%29.aspx" mce_href="http://msdn.microsoft.com/en-us/library/dd375717(VS.85).aspx"&gt;MSDN article&lt;/a&gt; describes&amp;nbsp;two &lt;b&gt;additional &lt;/b&gt;properties that are required to enable your WPD application to transfer protected content.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;table rules="rows" border="0" cols="2" frame="below"&gt;
&lt;tbody&gt;
&lt;tr valign="top"&gt;
&lt;td class="blue" width="50%"&gt;&lt;b&gt;Property&lt;/b&gt;&lt;/td&gt;
&lt;td class="blue" width="20%"&gt;&lt;b&gt;Vartype&lt;/b&gt;&lt;/td&gt;
&lt;td class="blue" width="30%"&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr valign="top"&gt;
&lt;td width="50%"&gt;WPD_CLIENT_WMDRM_APPLICATION_PRIVATE_KEY &lt;/td&gt;
&lt;td width="20%"&gt;VT_VECTOR | VT_UI1 &lt;/td&gt;
&lt;td width="30%"&gt;Specifies the application's private key.&lt;/td&gt;&lt;/tr&gt;
&lt;tr valign="top"&gt;
&lt;td width="50%"&gt;WPD_CLIENT_WMDRM_APPLICATION_CERTIFICATE &lt;/td&gt;
&lt;td width="20%"&gt;VT_VECTOR | VT_UI1 &lt;/td&gt;
&lt;td width="30%"&gt;Specifies the application's certificate.&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;
&lt;p&gt;To initialize WPD for protected content, call &lt;i&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd375690%28VS.85%29.aspx" title="IPortableDevice::Open" mce_href="http://msdn.microsoft.com/en-us/library/dd375690(VS.85).aspx"&gt;IPortableDevice::Open()&lt;/a&gt; &lt;/i&gt;with the above parameters added to the pClientInfo IPortableDeviceValues.&amp;nbsp;&amp;nbsp;If this succeeds, you can use the derived&amp;nbsp;&lt;i&gt;IPortableDeviceContent &lt;/i&gt;interface (from &lt;i&gt;IPortableDevice::Content()&lt;/i&gt;) to transfer protected (and clear)&amp;nbsp;content using &lt;i&gt;IPortableDeviceContent::CreateObjectWithPropertiesAndData().&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;To obtain a private application key and certificate, visit &lt;a href="http://www.microsoft.com/windows/windowsmedia/licensing/Licensing_DRM_Apps.aspx" mce_href="http://www.microsoft.com/windows/windowsmedia/licensing/Licensing_DRM_Apps.aspx"&gt;this link&lt;/a&gt;. &lt;br&gt;&lt;a href="http://www.microsoft.com/windows/windowsmedia/licensing/Licensing_DRM_Apps.aspx"&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;Transferring Content&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;To transfer WMDRM protected content, use &lt;i&gt;IPortableDeviceContent::CreateObjectWithPropertiesAndData().&amp;nbsp;&amp;nbsp; &lt;/i&gt;The same CreateObjectWithPropetiesAndData API call can be used for &lt;b&gt;both &lt;/b&gt;protected and clear content without additional&amp;nbsp;options.&amp;nbsp;&amp;nbsp; The WPD API will automatically select the protected or clear channel&amp;nbsp;depending on whether the content is protected or clear.&amp;nbsp;&amp;nbsp;&amp;nbsp;It&amp;nbsp;interfaces with the WMDRM Secure Content Provider to process the WMDRM licenses.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Transferring Known Clear Content&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;If you've enabled&amp;nbsp;WPD&amp;nbsp;to handle protected content, but you know that a specific&amp;nbsp;file is not protected, you can tell WPD to skip the DRM processing by&amp;nbsp;setting&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/dd375699%28VS.85%29.aspx" title="WPD_API_OPTION_USE_CLEAR_DATA_STREAM" mce_href="http://msdn.microsoft.com/en-us/library/dd375699(VS.85).aspx"&gt;WPD_API_OPTION_USE_CLEAR_DATA_STREAM&lt;/a&gt; option to &lt;b&gt;TRUE &lt;/b&gt;in the input IPortableDeviceValues when calling &lt;i&gt;IPortableDeviceContent::CreateObjectWithPropertiesAndData() &lt;/i&gt;for clear content.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Accessing Metering Operations using IWMDRMDeviceApp&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;WPD&amp;nbsp;provides a mechanism&amp;nbsp;to access the&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/bb231938%28VS.85%29.aspx" title="IWMDRMDeviceApp" mce_href="http://msdn.microsoft.com/en-us/library/bb231938(VS.85).aspx"&gt;&lt;i&gt;IWMDRMDeviceApp &lt;/i&gt;APIs&lt;/a&gt; for license updates and metering data retrieval.&amp;nbsp; &lt;b&gt;To access IWMDRMDeviceApp through WPD&lt;/b&gt;, call &lt;i&gt;QueryInterface&lt;/i&gt; on &lt;i&gt;IID_IWMDRMDeviceApp&lt;/i&gt; from the &lt;i&gt;IStream&amp;nbsp;&lt;/i&gt;returned from &lt;i&gt;IPortableDeviceContent::CreateObjectWithPropertiesAndData()&lt;/i&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;This IWMDRMDeviceApp instance&amp;nbsp;tied to the&amp;nbsp;IPortableDevice connection to your WMDRM-compatible device, and not the specific content&amp;nbsp;where the IStream was obtained.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WPD internally wraps the metering APIs and makes it accessible to your application.&amp;nbsp;&amp;nbsp; Your application&amp;nbsp;uses a constant for the IWMDMDevice* parameter:&amp;nbsp; &lt;b&gt;WMDRMDEVICEAPP_USE_WPD_DEVICE_PTR&lt;/b&gt;.&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;IStream*&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;pDataStream = NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;IWMDRMDeviceApp* &lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;pWMDRMApp &lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;= NULL;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;// ... Initialization &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;hr&amp;nbsp;= pPortableDeviceContent-&amp;gt;CreateObjectWithPropertiesAndData(&lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;pValues,&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&amp;amp;pDataStream,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;amp;dwOptimalWriteBufferSize,&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;NULL);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;// ... Transfer the protected WMDRM content &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;pDataStream-&amp;gt;Write(pData, cbData, &amp;amp;cbWritten);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;pDataStream-&amp;gt;Commit(0);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;hr = pDataStream-&amp;gt;QueryInterface(IID_IWMDRMDeviceApp, &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (void**)&amp;amp;pWMDRMApp);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;if (SUCCEEDED(hr))&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DWORD dwStatus&amp;nbsp;= 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;// Call metering operations on the current device using the WPD device pointer&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=""&gt;&amp;nbsp;&lt;/span&gt;hr = pWMDRMApp-&amp;gt;QueryDeviceStatus((IWMDMDevice *)WMDRMDEVICEAPP_USE_WPD_DEVICE_PTR, &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&amp;amp;dwStatus);&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: 9pt; font-family: 'Courier New';"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;The same pre-requisitie with the application private key and certificate applies here as well.&amp;nbsp;&amp;nbsp; If the key/certificate is invalid or if the WMDRM system fails to initialize, the QueryInferface call will fail.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;Update [March 13, 2007]:&lt;/b&gt;&amp;nbsp; The above method to acquire the IWMDRMDeviceApp interface from the IStream pointer is just a &lt;i&gt;convenience&lt;/i&gt; if your application is already doing a &lt;i&gt;prior protected&amp;nbsp;content transfer&lt;/i&gt;&lt;b&gt;,&lt;/b&gt; before proceeding on to do metering and license synchronization operations.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;Our recommendation for most applications that need to access IWMDRMDeviceApp is to initialize IWMDRMDeviceApp directly as this does not require your application&amp;nbsp;to transfer protected content or hold on to the transfer interfaces in order to do device metering and license sync.&amp;nbsp;&amp;nbsp; For details, refer to &lt;a href="http://msdn.microsoft.com/en-us/library/bb231629%28VS.85%29.aspx" title="Handling Protected Content using WMDRMDeviceApp" mce_href="http://msdn.microsoft.com/en-us/library/bb231629(VS.85).aspx"&gt;this MSDN article&lt;/a&gt; entitled "Handling Protected Content in the Application."&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;Update [May 5, 2007]:&amp;nbsp; &lt;/b&gt;The whitepaper (and sample code)&amp;nbsp;on initializing IWMDRMDeviceApp for WPD is&amp;nbsp;now&amp;nbsp;posted &lt;a href="http://www.microsoft.com/whdc/device/media/WMDRM_API.mspx" class="" title="Accessing WMDRM APIs from WPD" mce_href="http://www.microsoft.com/whdc/device/media/WMDRM_API.mspx"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1638560" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WMDM/default.aspx">WMDM</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/DRM/default.aspx">DRM</category></item><item><title>Which Portable Devices?</title><link>http://blogs.msdn.com/wpdblog/archive/2007/01/27/which-devices-can-my-application-enumerate-using-wpd.aspx</link><pubDate>Sat, 27 Jan 2007 11:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1541885</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1541885.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1541885</wfw:commentRss><description>&lt;p&gt;&lt;b&gt;What devices does WPD support?&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A&amp;nbsp;WPD application (e.g. the &lt;a href="http://msdn.microsoft.com/en-us/library/dd389001%28VS.85%29.aspx" title="WPD API Sample" mce_href="http://msdn.microsoft.com/en-us/library/dd389001(VS.85).aspx"&gt;WPD API Sample&lt;/a&gt;) on &lt;b&gt;Windows XP&lt;/b&gt; (with the pre-requisites installed) can connect to these devices:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Devices (e.g. portable media players, cameras, some phones) that support &lt;a href="http://en.wikipedia.org/wiki/Media_Transfer_Protocol" class="" title="MTP in Wikipedia" mce_href="http://en.wikipedia.org/wiki/Media_Transfer_Protocol"&gt;Media Transfer Protocol&lt;/a&gt; (MTP). &lt;/li&gt;
&lt;li&gt;Devices that connect using third party or vendor provided WPD drivers.&amp;nbsp; &lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;A WPD application on &lt;b&gt;Windows Vista&lt;/b&gt; can connect to even more devices:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Devices (e.g. portable media players, cameras, some phones) that support MTP.&amp;nbsp; &lt;/li&gt;
&lt;li&gt;Devices that connect using third party or vendor provided WPD drivers.&lt;/li&gt;
&lt;li&gt;Devices (e.g. cameras, camcorders) that support &lt;a href="http://en.wikipedia.org/wiki/Picture_Transfer_Protocol" class="" title="PTP Wikipedia" mce_href="http://en.wikipedia.org/wiki/Picture_Transfer_Protocol"&gt;Picture Transfer Protocol&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;USB Mass Storage Devices.&lt;/li&gt;
&lt;li&gt;Windows CE devices via IPortableDeviceManager::GetPrivateDevices()&lt;/li&gt;&lt;/ul&gt;
&lt;p mce_keep="true"&gt;In both cases, the WPD Shell Namespace Extension is&amp;nbsp;also a&amp;nbsp;WPD application, so you can check whether your device is visible to WPD by browsing to it using Explorer ("My Computer").&amp;nbsp; &lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;What about a Smartphone or PocketPC device?&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;On Windows Vista, Windows CE devices&amp;nbsp;register the private WPD interface GUID, and can be enumerated in WPD&amp;nbsp;by&amp;nbsp;calling &lt;i&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/dd388694%28VS.85%29.aspx" title="IPortableDeviceManager::GetPrivateDevices" mce_href="http://msdn.microsoft.com/en-us/library/dd388694(VS.85).aspx"&gt;IPortableDeviceManager::GetPrivateDevices()&lt;/a&gt;&lt;/i&gt;.&amp;nbsp; These devices connect to Explorer using the WPD RAPI driver, which provides&amp;nbsp;device browsing&amp;nbsp;functionality.&amp;nbsp;&amp;nbsp; Content sync is&amp;nbsp;implemented&amp;nbsp;through a different channel.&amp;nbsp;&amp;nbsp; The WPD RAPI driver is not available on Windows XP.&lt;/p&gt;
&lt;p mce_keep="true"&gt;On Windows Vista and Windows XP, to enumerate content on a Windows CE device for Windows Media Player applications,&amp;nbsp;you can use the &lt;a href="http://msdn.microsoft.com/en-us/library/bb231982%28VS.85%29.aspx" title="WMDM API" mce_href="http://msdn.microsoft.com/en-us/library/bb231982(VS.85).aspx"&gt;Windows Media Device Manager (WMDM) APIs&lt;/a&gt;.&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;b&gt;How do I install WPD?&lt;/b&gt;&lt;/p&gt;
&lt;p mce_keep="true"&gt;On Windows XP, WPD is available when &lt;b&gt;any one&lt;/b&gt; of these pre-requistes&amp;nbsp;are installed:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Windows Media Player 11&lt;/li&gt;
&lt;li&gt;The redistributable package bundled with &lt;a href="http://msdn.microsoft.com/en-us/windows/bb190309.aspx" title="Windows Media Format 11 SDK Download Link" mce_href="http://msdn.microsoft.com/en-us/windows/bb190309.aspx"&gt;Windows Media Format 11 SDK&lt;/a&gt; (see &lt;a href="http://msdn2.microsoft.com/en-us/library/aa468619.aspx#redistributables__parm" class="" title="release notes" mce_href="http://msdn2.microsoft.com/en-us/library/aa468619.aspx#redistributables__parm"&gt;release notes&lt;/a&gt;)&lt;/li&gt;&lt;/ol&gt;
&lt;p mce_keep="true"&gt;On Windows Vista, WPD is supported natively for&amp;nbsp;SKUs that include Windows Media Player (e.g. Home Basic, Home Premium, Ultimate Edition ...)&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;&lt;/i&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1541885" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/MTP/default.aspx">MTP</category></item><item><title>Getting Your Feet Wet .... with WPD Development</title><link>http://blogs.msdn.com/wpdblog/archive/2007/01/23/getting-your-feet-wet-with-wpd-development.aspx</link><pubDate>Tue, 23 Jan 2007 21:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1516199</guid><dc:creator>wpdblog</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/wpdblog/comments/1516199.aspx</comments><wfw:commentRss>http://blogs.msdn.com/wpdblog/commentrss.aspx?PostID=1516199</wfw:commentRss><description>&lt;p&gt;Here’s a common question we get from developers:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“I read about WPD from the &lt;a href="http://msdn.microsoft.com/en-us/library/dd388998%28VS.85%29.aspx" title="WPD on MSDN" mce_href="http://msdn.microsoft.com/en-us/library/dd388998(VS.85).aspx"&gt;MSDN library&lt;/a&gt;, but where do I download the samples, tools and build environment that are mentioned in the docs?“&lt;br&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;b&gt;Writing a WPD Application&lt;/b&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To get started on developing a WPD application, download the &lt;a href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx" title="Windows SDK" mce_href="http://msdn.microsoft.com/en-us/windows/bb980924.aspx"&gt;Windows SDK&lt;/a&gt;.&amp;nbsp; This contains the header and library files, build environment, and code for a sample WPD application. &lt;/p&gt;
&lt;p&gt;&lt;b&gt;Writing a WPD Driver &lt;/b&gt;&lt;/p&gt;
&lt;p&gt;To get started on developing a WPD driver, download the &lt;a href="http://www.microsoft.com/whdc/devtools/WDK/default.mspx" class="" title="Windows Driver Kit" mce_href="http://www.microsoft.com/whdc/devtools/WDK/default.mspx"&gt;Windows Driver Kit&lt;/a&gt;.&amp;nbsp;&amp;nbsp; This contains sample drivers, tools, build environment, and documentation for WPD and User Mode Driver Framework.&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;We recommend using WPDInfo and WPDMon as debugging and testing tools for driver development.&amp;nbsp;&amp;nbsp; These are bundled into the Windows Driver Kits.&amp;nbsp; For more details on these tools, refer to the &lt;a href="http://download.microsoft.com/download/5/D/6/5D6EAF2B-7DDF-476B-93DC-7CF0072878E6/WPD_tips.doc" class="" title="WPD Tips" mce_href="http://download.microsoft.com/download/5/D/6/5D6EAF2B-7DDF-476B-93DC-7CF0072878E6/WPD_tips.doc"&gt;"WPD Tips" Whitepaper&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Need more tips and tricks?&amp;nbsp; One of our WPD enthusiasts has written a &lt;a href="http://blogs.msdn.com/dimeby8" class="" title="DimeBy8" mce_href="http://blogs.msdn.com/dimeby8"&gt;blog&lt;/a&gt; with tons of WPD and Media Transfer Protocol (MTP) how-tos.&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&amp;nbsp;&lt;/p&gt;
&lt;p mce_keep="true"&gt;&lt;i&gt;This posting is provided "AS IS" with no warranties, and confers no rights.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1516199" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/wpdblog/archive/tags/SDK/default.aspx">SDK</category><category domain="http://blogs.msdn.com/wpdblog/archive/tags/WDK/default.aspx">WDK</category></item></channel></rss>