wmi - Trying to access battery level, c# -


i'm trying create app windows 8 using c# display current battery level. i'm trying query win32_battery class relevant properties,but i'm getting unusual result. here's code:

private void btn1_click(object sender, eventargs e) {     managementobjectsearcher searcher = new managementobjectsearcher("select * win32_battery");     managementobjectcollection collection = searcher.get();     foreach (managementobject obj in collection)     {         txtbox.appendtext(obj.tostring() + "\r\n");     }; } 

my result in txtbox is

\\mikeslaptop\root\cimv2:win32_battery.deviceid=" asustekx401-44" 

any ideas why reading thedevideid property? guidance appreciated.

this expected output. forgot enumerate properties of query. make similar this:

    foreach (managementobject obj in searcher.get()) {         foreach (var prop in obj.properties) {             if (prop.value != null) {                 txtbox.appendtext(string.format("{0} = {1}", prop.name, prop.value));             }         }     } 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -