C#得到系统信息
//cpu频率
using Microsoft.Win32;
private int GetCPUFrequency()
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
object obj = rk.GetValue("~MHz");
int CPUFrequency = (int)obj;
return CPUFrequency;
}
private int GetCPUFrequency()
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
object obj = rk.GetValue("~MHz");
int CPUFrequency = (int)obj;
return CPUFrequency;
}
//////////////////////////////////
//磁盘空间 Management
using System.Management;
private long GetFreeDiskSpace()
{
ManagementObject disk = new ManagementObject(
"win32_logicaldisk.deviceid=\"d:\"");
disk.Get();
string totalByte = disk["FreeSpace"].ToString();
long freeDiskSpaceMb = Convert.ToInt64(totalbyte)/1024/1024;
return freeDiskSpaceMb;
}
private long GetFreeDiskSpace()
{
ManagementObject disk = new ManagementObject(
"win32_logicaldisk.deviceid=\"d:\"");
disk.Get();
string totalByte = disk["FreeSpace"].ToString();
long freeDiskSpaceMb = Convert.ToInt64(totalbyte)/1024/1024;
return freeDiskSpaceMb;
}
/////////////////////
//内存信息
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
//////////////////////////////
//cpu名字
using Microsoft.Win32;
private string GetCPUName()
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
object obj = rk.GetValue("ProcessorNameString");
string CPUName = (string)obj;
return CPUName.TrimStart();
}
private string GetCPUName()
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0");
object obj = rk.GetValue("ProcessorNameString");
string CPUName = (string)obj;
return CPUName.TrimStart();
}
///////////////////////
//OS版本
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://anf.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)