blob: adf6a26555a3d520e2316cabe9c52df3da4a2b0b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PowerService.cs" company="HandBrake Project (http://handbrake.fr)">
// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
// The Power Service
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace HandBrakeWPF.Services
{
using System;
using System.Management;
using HandBrakeWPF.Utilities;
public class PowerService
{
public static bool HasBattery()
{
Win32.PowerState state = Win32.PowerState.GetPowerState();
if (state == null || state.BatteryFlag == Win32.BatteryFlag.NoSystemBattery)
{
return false;
}
return true;
}
private void GetPowerState()
{
System.Management.ObjectQuery query = new ObjectQuery("Select * FROM Win32_Battery");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
ManagementObjectCollection collection = searcher.Get();
foreach (ManagementObject mo in collection)
{
foreach (PropertyData property in mo.Properties)
{
Console.WriteLine("Property {0}: Value is {1}", property.Name, property.Value);
}
}
}
}
}
|