Answered by:
how to obtain more info from DeviceWatcher?

Question
-
Hi,
from the DeviceWatcher class, there're events for added, updated, removed, etc, but how could I get more information out of it? Info like Model Name, device Name, connection, etc.
I couldn't get much out from parameters DeviceWatcher and DeviceInformationUpdate classes.
Currently, the only way I know to obtain those information is through using DeviceInformation class or PnpObject class with .FindAllAsync() or derived methods.
string[] properties = { "System.ItemNameDisplay", "System.Devices.ModelName", "System.Devices.Connected" };
var containers = await PnpObject.FindAllAsync(PnpObjectType.DeviceContainer, properties);
however, it is inconvenient and wasteful to update the entire device list if I already know there is one device updated.
var results = await DeviceInformation.FindAllAsync(); foreach (var result in results) { try { Debug.WriteLine("device: {0}", result.Name.ToString()); Debug.WriteLine("\t Id: {0}", result.Id.ToString()); foreach (var prop in result.Properties) Debug.WriteLine("\t key: {0}, value: {1}", prop.Key, prop.Value); } catch(Exception ex) { } }
Thanks!
Jerry
- Moved by Rob Caplan [MSFT]Microsoft employee, Moderator Monday, May 21, 2012 9:02 AM (From:Building Metro style apps with C# or VB )
Monday, May 21, 2012 9:00 AM
Answers
-
Jerry,
This page shows how to use DeviceWatcher to print out device properties when an added event is received.
http://msdn.microsoft.com/en-us/library/windows/apps/hh465007.aspx
I also posted a second more detailed answer on your other thread.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:45 PM
Friday, May 25, 2012 5:45 PMModerator
All replies
-
Jerry,
I will see if there is a way to update just one device.
Best Wishes - Eric
Tuesday, May 22, 2012 2:18 PMModerator -
Jerry,
I am still researching this for you.
Best Wishes - Eric
Friday, May 25, 2012 5:25 AMModerator -
Jerry,
This page shows how to use DeviceWatcher to print out device properties when an added event is received.
http://msdn.microsoft.com/en-us/library/windows/apps/hh465007.aspx
I also posted a second more detailed answer on your other thread.
Best Wishes - Eric
- Marked as answer by Eric Hanson-MSFTModerator Friday, May 25, 2012 5:45 PM
Friday, May 25, 2012 5:45 PMModerator