ObjectQuery query = new ObjectQuery("Select * FROM Win32_Battery");
foreach (ManagementObject o in new ManagementObjectSearcher(query).Get())
{
uint level = (uint)o.Properties["EstimatedChargeRemaining"].Value;
}
Simple in c# - really cannot get my head around it in vb.net -> tried online and manual conversion and keep getting stuck
For Each o As ManagementObject In New ManagementObjectSearcher(query2)
<- getting stuck at this point I think -> not sure how to do the .get
If anyone can help me convert that would be wonderful - preferably the full conversion as I have found parts of my answer all over and they all seem to 'miss a step'
Pretty much exactly as you'd expect:
Dim query As New ObjectQuery("Select * FROM Win32_Battery")
For Each o As ManagementObject In New ManagementObjectSearcher(query).Get()
Dim level = CUInt(o.Properties("EstimatedChargeRemaining").Value)
Next
Have you tried developerFusion site to covert your code. The following code has converted from developer fusion.
Dim query As New ObjectQuery("Select * FROM Win32_Battery")
For Each o As ManagementObject In New ManagementObjectSearcher(query).[Get]()
Dim level As UInteger = CUInt(o.Properties("EstimatedChargeRemaining").Value)
Next
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.