Exemple #1
0
        private string [] GetWmiClass(WMICLASS wmi)
        {
            string [] result;

            int Index = 0;

            result = new String[1024 * 2];

            try
            {
                ManagementObjectSearcher query1 = new  ManagementObjectSearcher("SELECT * FROM " + WmiClass[(int)wmi]);
                foreach (ManagementObject mo in query1.Get())
                {
                    foreach (PropertyData property in mo.Properties)
                    {
                        // write the propert name and the property value
                        result[Index++] = (property.Name + " = " + property.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                result[0] = ex.Message;
            }
            return(result);
        }
Exemple #2
0
    private string [] GetWmiClass(WMICLASS wmi)
    {
      string [] result;

      int Index=0;
      result = new String[1024*2];

      try
      {
        ManagementObjectSearcher query1 = new  ManagementObjectSearcher("SELECT * FROM " + WmiClass[(int)wmi]); 
        foreach( ManagementObject mo in query1.Get() ) 
        {
          foreach (PropertyData property in mo.Properties)
          {
            // write the propert name and the property value
            result[Index++]=(property.Name + " = " + property.Value);
          }
        }   
      }
      catch(Exception ex)
      {
        result[0]= ex.Message ;
      }
      return result;
    }