Exemplo n.º 1
0
		protected List<ProcessorDTOResponse> GetWinLTE6ProcessorsInfo()
		{
			List<ProcessorDTOResponse> processors = new List<ProcessorDTOResponse>();
			Hashtable uniqueProcessors = new Hashtable();
			int totalDetectedCPUs = 0;
			
			try
			{
				SelectQuery query = new SelectQuery(
					@"select 
						Name,  
						DeviceID, 
						MaxClockSpeed, 
						Caption, 
						Manufacturer, 
						DataWidth,
						SocketDesignation
					  from Win32_Processor"
				);
				ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
				
				foreach (ManagementObject obj in searcher.Get())
				{
					totalDetectedCPUs++;
					
					string socketDesignation = GetValueAsString(obj, "SocketDesignation");
					if (uniqueProcessors.ContainsKey(socketDesignation))
					{
						continue;
					}
					
					ProcessorDTOResponse processor = new ProcessorDTOResponse();
					if (vendor.IndexOf("xen") > -1 || vendor.IndexOf("vmware") > -1 || vendor.IndexOf("bochs") > -1)
					{
						processor.Label = "Virtual " + GetValueAsString(obj, "Name");
						processor.Family = "Virtual " + GetValueAsString(obj, "Caption");
					}
					else
					{
						processor.Label = GetValueAsString(obj, "Name");
						processor.Family = GetValueAsString(obj, "Caption");
					}
					processor.Speed = GetValueAsString(obj, "MaxClockSpeed");
					processor.Index = GetValueAsString(obj, "DeviceID");
					processor.ModelName = processor.Label + " " + processor.Speed + "Mhz";
					
					uniqueProcessors.Add(socketDesignation, processor);
				}
			}
			catch (ManagementException e)
			{
				Logger.Instance.LogError(e.ToString());
			}
			
			if (uniqueProcessors.Count > 0)
			{
				int coresCount = totalDetectedCPUs / uniqueProcessors.Count;
				foreach (ProcessorDTOResponse cpu in uniqueProcessors.Values)
				{
					cpu.Cores = coresCount.ToString();
					
					processors.Add(cpu);
				}
			}
			
			return processors;
		}
Exemplo n.º 2
0
        public List<ProcessorDTOResponse> GetProcessorsInfo()
        {
            List<ProcessorDTOResponse> processors = new List<ProcessorDTOResponse>();

            try
            {
                SelectQuery query = new SelectQuery(
                    @"select
                        Name,
                        Description,
                        DeviceID,
                        MaxClockSpeed,
                        NumberOfCores,
                        NumberOfLogicalProcessors,
                        Caption,
                        Manufacturer,
                        Version,
                        DataWidth
                      from Win32_Processor"
                );
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

                foreach (ManagementObject obj in searcher.Get())
                {
                    ProcessorDTOResponse processor = new ProcessorDTOResponse();
                    processor.Label = GetValueAsString(obj, "Name");
                    processor.Speed = GetValueAsString(obj, "MaxClockSpeed");
                    processor.Cores = GetValueAsString(obj, "NumberOfCores");
                    processor.Index = GetValueAsString(obj, "DeviceID");
                    processor.Description = GetValueAsString(obj, "Description");
                    processor.NumberOfLogicalProcessors = GetValueAsString(obj, "NumberOfLogicalProcessors");
                    processor.Caption = GetValueAsString(obj, "Caption");
                    processor.Manufacturer = GetValueAsString(obj, "Manufacturer");
                    processor.Version = GetValueAsString(obj, "Version");
                    if (GetValueAsString(obj, "DataWidth") == "64") {
                        processor.Is64Bit = "true";
                    }
                    else
                    {
                        processor.Is64Bit = "false";
                    }

                    processors.Add(processor);
                }
            }
            catch (ManagementException e)
            {
                Logger.Instance.LogError(e.ToString());
            }

            return processors;
        }
Exemplo n.º 3
0
		protected List<ProcessorDTOResponse> GetWinGTE6ProcessorsInfo()
		{
			List<ProcessorDTOResponse> processors = new List<ProcessorDTOResponse>();

			try
			{
				SelectQuery query = new SelectQuery(
					@"select 
						Name, 
						DeviceID, 
						MaxClockSpeed, 
						NumberOfCores, 
						NumberOfLogicalProcessors, 
						Caption, 
						Manufacturer, 
						DataWidth
					  from Win32_Processor"
				);
				ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

				foreach (ManagementObject obj in searcher.Get())
				{
					ProcessorDTOResponse processor = new ProcessorDTOResponse();
					if (vendor.IndexOf("xen") > -1 || vendor.IndexOf("vmware") > -1 || vendor.IndexOf("bochs") > -1)
					{
						processor.Label = "Virtual " + GetValueAsString(obj, "Name");
						processor.Family = "Virtual " + GetValueAsString(obj, "Caption");
					}
					else
					{
						processor.Label = GetValueAsString(obj, "Name");
						processor.Family = GetValueAsString(obj, "Caption");
					}
					processor.Speed = GetValueAsString(obj, "MaxClockSpeed");
					processor.Cores = GetValueAsString(obj, "NumberOfCores");
					processor.Index = GetValueAsString(obj, "DeviceID");
					processor.ModelName = processor.Label + " " + processor.Speed + "Mhz";
					
					processors.Add(processor);
				}
			}
			catch (ManagementException e)
			{
				Logger.Instance.LogError(e.ToString());
			}
			
			return processors;
		}