Exemplo n.º 1
0
 public void clearStatusCode(int statusCode, bool bitwise)
 {
     lock (this._lockStatusCode)
     {
         int num = statusCode;
         try
         {
             string      name        = "SOFTWARE\\ATEN\\ecoSensors";
             RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(name, true);
             if (registryKey != null)
             {
                 if (registryKey.GetValue("ServiceStatus") != null)
                 {
                     int num2 = (int)registryKey.GetValue("ServiceStatus");
                     if (bitwise)
                     {
                         int num3 = ~statusCode;
                         num = (num2 & num3);
                     }
                     if (num != num2)
                     {
                         registryKey.SetValue("ServiceStatus", num);
                         DebugCenter.GetInstance().appendToFile("Service Status from 0x" + num2.ToString("X4") + " to 0x" + num.ToString("X4"));
                     }
                 }
                 registryKey.Close();
             }
         }
         catch (Exception ex)
         {
             DebugCenter.GetInstance().appendToFile("clearStatusCode: " + ex.Message);
         }
     }
 }
Exemplo n.º 2
0
 public void setLastStatusCode(int statusCode, bool bitwise)
 {
     lock (this._lockStatusCode)
     {
         int num = statusCode;
         try
         {
             string      text        = "SOFTWARE\\ATEN\\ecoSensors";
             RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(text, true);
             if (registryKey == null)
             {
                 registryKey = Registry.LocalMachine.CreateSubKey(text);
                 if (registryKey != null)
                 {
                     registryKey.SetValue("ServiceStatus", num);
                     DebugCenter.GetInstance().appendToFile("Failed to read register, create and set the register(set)");
                 }
             }
             if (registryKey != null)
             {
                 if (registryKey.GetValue("ServiceStatus") != null)
                 {
                     int num2 = (int)registryKey.GetValue("ServiceStatus");
                     if (bitwise)
                     {
                         num |= num2;
                     }
                     if (num != num2)
                     {
                         registryKey.SetValue("ServiceStatus", num);
                         DebugCenter.GetInstance().appendToFile("Service Status from 0x" + num2.ToString("X4") + " to 0x" + num.ToString("X4"));
                     }
                 }
                 else
                 {
                     registryKey.SetValue("ServiceStatus", num);
                     DebugCenter.GetInstance().appendToFile("Failed to read ServiceStatus, create and set the register(set)");
                 }
                 registryKey.Close();
             }
         }
         catch (Exception ex)
         {
             DebugCenter.GetInstance().appendToFile("setLastStatusCode: " + ex.Message);
         }
     }
 }
Exemplo n.º 3
0
        public int getLastStatusCode()
        {
            int result;

            lock (this._lockStatusCode)
            {
                int num = 0;
                try
                {
                    string      text        = "SOFTWARE\\ATEN\\ecoSensors";
                    RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(text, true);
                    if (registryKey == null)
                    {
                        registryKey = Registry.LocalMachine.CreateSubKey(text);
                        if (registryKey != null)
                        {
                            registryKey.SetValue("ServiceStatus", 0);
                            DebugCenter.GetInstance().appendToFile("Failed to read registry, create and set the register(get)");
                        }
                    }
                    if (registryKey != null)
                    {
                        if (registryKey.GetValue("ServiceStatus") != null)
                        {
                            num = (int)registryKey.GetValue("ServiceStatus");
                            DebugCenter.GetInstance().appendToFile("Service Status: 0x" + num.ToString("X4"));
                        }
                        else
                        {
                            registryKey.SetValue("ServiceStatus", 0);
                            DebugCenter.GetInstance().appendToFile("Failed to read ServiceStatus, create and set the register(get)");
                        }
                        registryKey.Close();
                    }
                }
                catch (Exception ex)
                {
                    DebugCenter.GetInstance().appendToFile("getLastStatusCode: " + ex.Message);
                }
                result = num;
            }
            return(result);
        }