Answered by:
DeviceWatcher vs PnpObjectWatcher

Question
-
Hello,
Could anyone please tell me the difference between DeviceWatcher and PnpObjectWatcher?
I read them on MSDN, but I still couldn't tell the differences.
Both classes share the same Events, Methods, and Properties.
and I don't understand the differences between Pnp object and device object.
Thanks!
Jerry
- Moved by Rob Caplan [MSFT]Microsoft employee, Moderator Monday, May 21, 2012 8:34 AM (From:Building Metro style apps with C# or VB )
Monday, May 21, 2012 8:23 AM
Answers
-
Jerry,
Use the DeviceWatcher class to enumerate devices dynamically, so that the app receives notifications if devices are added, removed, or changed after the initial enumeration is complete.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:21 AM
Friday, May 25, 2012 5:21 AMModerator -
Jerry,
DeviceWatcher (and DeviceInformation) only operates on interfaces (and their properties), while PnpWatcher (and PnpObject) can also look for other object types (e.g. containers).
So if you use DeviceWatcher, in your callback you can fetch any property set on the interface specified by the DeviceInformation object that gets returned.
This page has the list of canonical properties for all object types, and also shows how to specify properties using the GUID PID format:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465007.aspx
Best Wishes - Eric- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:22 PM
Friday, May 25, 2012 5:22 PMModerator
All replies
-
Jerry,
I will research this fo you.
Best Wishes - Eric
Tuesday, May 22, 2012 2:19 PMModerator -
Jerry,
Use the DeviceWatcher class to enumerate devices dynamically, so that the app receives notifications if devices are added, removed, or changed after the initial enumeration is complete.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:21 AM
Friday, May 25, 2012 5:21 AMModerator -
Jerry,
DeviceWatcher (and DeviceInformation) only operates on interfaces (and their properties), while PnpWatcher (and PnpObject) can also look for other object types (e.g. containers).
So if you use DeviceWatcher, in your callback you can fetch any property set on the interface specified by the DeviceInformation object that gets returned.
This page has the list of canonical properties for all object types, and also shows how to specify properties using the GUID PID format:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465007.aspx
Best Wishes - Eric- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:22 PM
Friday, May 25, 2012 5:22 PMModerator -
ok, thanks a lot for the answer, Eric!
Jerry
Monday, May 28, 2012 2:47 AM -
You are most welcome Jerry.
Best Wishes - Eric
Tuesday, May 29, 2012 2:45 PMModerator