diff options
| author | James Barnett <james.barnett@fivium.co.uk> | 2017-07-27 13:02:31 +0100 |
|---|---|---|
| committer | James Barnett <james.barnett@fivium.co.uk> | 2017-07-27 13:02:31 +0100 |
| commit | 36776bfbff6f15f7239924777651392945ebb2a0 (patch) | |
| tree | 8e4c75b40bc45b888773cac33c9bbbf165da6fd9 /NucLedController/WMISystemManagement.cs | |
| parent | b9c3039f0787c9ede5abf0da750615e4eced8f60 (diff) | |
| download | intel-nuc-led-controller-0.1.tar.xz intel-nuc-led-controller-0.1.zip | |
Rejig folder structurev0.1
Diffstat (limited to 'NucLedController/WMISystemManagement.cs')
| -rw-r--r-- | NucLedController/WMISystemManagement.cs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/NucLedController/WMISystemManagement.cs b/NucLedController/WMISystemManagement.cs new file mode 100644 index 0000000..bd3b9cd --- /dev/null +++ b/NucLedController/WMISystemManagement.cs @@ -0,0 +1,41 @@ +using System; +using System.Management; + +namespace NucLedController +{ + public sealed class WMISystemManagement + { + private static readonly string OBJECT_SEARCHER_SCOPE = "\\root\\WMI"; + private static readonly string OBJECT_SEARCHER_QUERY_STRING = "SELECT * FROM CISD_WMI"; + private static readonly string SET_LED_METHOD_NAME = "SetState"; + + private static readonly WMISystemManagement INSTANCE = new WMISystemManagement(); + + private EnumerationOptions enumerationOptions; + private ManagementObjectSearcher objectSearcher; + + private WMISystemManagement() + { + enumerationOptions = new EnumerationOptions(); + enumerationOptions.ReturnImmediately = false; + objectSearcher = new ManagementObjectSearcher(OBJECT_SEARCHER_SCOPE, OBJECT_SEARCHER_QUERY_STRING, enumerationOptions); + } + + public static WMISystemManagement Instance + { + get { return INSTANCE; } + } + + public void WriteData(byte[] data) + { + + foreach (ManagementObject queryObj in objectSearcher.Get()) + { + queryObj.InvokeMethod(SET_LED_METHOD_NAME, new object[] { BitConverter.ToInt32(data, 0) }); + queryObj.Dispose(); + } + + } + + } +} |