Ejemplo n.º 1
0
        public List <String> getProcessorPowerInfo()
        {
            List <String> list = new List <string>();

            SYSTEM_INFO sysinfo = new SYSTEM_INFO();

            GetSystemInfo(ref sysinfo);

            PROCESSOR_POWER_INFORMATION[] ppi = new PROCESSOR_POWER_INFORMATION[sysinfo.dwNumberOfProcessors];
            uint retval = CallNtPowerInformation(
                ProcessorPowerInformation,
                IntPtr.Zero,
                0,
                ppi,
                ppi.Length * Marshal.SizeOf(typeof(PROCESSOR_POWER_INFORMATION))
                );

            if (retval == STATUS_SUCCESS)
            {
                list.Add(ppi[0].CurrentIdleState.ToString());
                list.Add(ppi[0].CurrentMhz.ToString());
                list.Add(ppi[1].MaxIdleState.ToString());
                list.Add(ppi[0].MaxMhz.ToString());
                list.Add(ppi[0].MhzLimit.ToString());
            }
            return(list);
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            int procCount = Environment.ProcessorCount;

            PROCESSOR_POWER_INFORMATION[] procInfo =
                new PROCESSOR_POWER_INFORMATION[procCount];
            uint retval = CallNtPowerInformation(
                ProcessorInformation,
                IntPtr.Zero,
                0,
                procInfo,
                procInfo.Length * Marshal.SizeOf(typeof(PROCESSOR_POWER_INFORMATION))
                );

            if (retval == STATUS_SUCCESS)
            {
                foreach (var item in procInfo)
                {
                    Console.WriteLine(item.CurrentMhz);
                }
            }
        }