diff options
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(); + } + + } + + } +} |