• 大小: 2.43M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2020-12-26
  • 语言: C#
  • 标签: 内存  CPU  显卡  c  硬盘  

资源简介

可检测主板、cpu、显卡、内存、硬盘等硬件的温度、频率、电压、风扇转速等。
使用openhardwaremonitor的动态库,为开源软件,有全部源码。
本例使用最新版0.8.0.2,可关注其官网更新。
无源码的DLL和控件谨慎使用。

官方提供的Demo基本看不成,太TM繁琐,就别费劲看官方Demo代码了,
花了一整天时间拆分原版demo,写了基本应用的例子,简化了很多,更容易修改应用到你的代码里面,
程序里用的“刷新”按钮,可改写为线程自动刷新,自行修改。
英文不好,如有文字和代码次序错误,自行参照原版修改。

编译运行需管理员权限,参见http://www.haolizi.net/example/view_10851.html管理权限编译部分,
或百度“C#管理员权限编译”。

原版图:

改写图:


computer.Accept(updateVisitor); //刷新
            int z = computer.Hardware.Length;
            int m,y,k;
            string str1, str2, sn, sx, sv;
            s_info = null;
            str1 = "";
            str2 = "";
            sn = "";
            sx = "";
            sv = "-";
            for (int i = 0; i < z; i  )
            {
                if (computer.Hardware[i].HardwareType == HardwareType.CPU) str1 = "处理器";
                if (computer.Hardware[i].HardwareType == HardwareType.Mainboard) str1 = "主板";
                if (computer.Hardware[i].HardwareType == HardwareType.RAM) str1 = "内存";
                if (computer.Hardware[i].HardwareType == HardwareType.GpuNvidia) str1 = "显卡";
                if (computer.Hardware[i].HardwareType == HardwareType.HDD) str1 = "硬盘";
                s_info  = str1   ":"   computer.Hardware[i].Name   "\r";

                if (computer.Hardware[i].HardwareType == HardwareType.Mainboard) //主板和别不一样是“下一级的下一级”
                {
                    m = computer.Hardware[i].SubHardware.Length;
                    if (m > 0)
                    {
                        for (int t = 0; t < m; t  )
                        {
                            s_info  = "******芯片:"   computer.Hardware[i].SubHardware[t].Name   "\r";
                            k = computer.Hardware[i].SubHardware[t].Sensors.Length;
                            if (k>0)
                            {
                                for (int u = 0; u < k; u  )
                                {
                                    if (computer.Hardware[i].SubHardware[t].Sensors[u].SensorType.ToString().Contains("Control")) str2 = "控制";
                                    sn = computer.Hardware[i].SubHardware[t].Sensors[u].Name;
                                    if (sn.Contains("Fan Control")) { sn = sn.Replace("Fan Control", "风扇控制"); sx = " RPM"; }
                                    if (sn.Contains("Voltage")) { sn =  sn.Replace("Voltage", "电压"); sx = " V";  }
                                    if (sn.Contains("Standby")) { sn =  sn.Replace("Standby", "备用"); sx = " V"; }
                                    if (sn.Contains("VBat")) { sn = sn.Replace("VBat", "电池电压"); sx = " V"; }
                                    if (sn.Contains("Temperature")) { sn = sn.Replace("Temperature", "温度"); sx = " ℃"; }
                                    if (sn.Contains("Fan")) { sn = sn.Replace("Fan", "风扇"); sx = " RPM"; }
                                    if (computer.Hardware[i].SubHardware[t].Sensors[u].Value.ToString() != "") sv = computer.Hardware[i].SubHardware[t].Sensors[u].Value.ToString();
                                    s_info  = "************"   str2   ":"   sn   ":"   sv   sx   "\r";
                                }
                            }
                        }
                    }
                }
                else
                {
                    y = computer.Hardware[i].Sensors.Length;
                    if (y > 0)
                    {
                        for (int j = 0; j < y; j  )
                        {
                            if (computer.Hardware[i].HardwareType == HardwareType.GpuNvidia)
                            {
                                if (computer.Hardware[i].Sensors[j].Name.ToString().Contains("GPU Fan"))
                                {
                                    str2 = "控制"; sx = " MB";
                                }  else
                                {
                                    if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Data) { str2 = "数据"; sx = " MB"; }
                                    if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Control) { str2 = "控制"; sx = " MB"; }
                                }
                            }
                            else
                            {
                                if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Data) { str2 = "数据"; sx = " GB"; }
                            }
                            if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Clock) { str2 = "频率"; sx = " MHz"; }
                            if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Load) { str2 = "使用"; sx = " %"; }
                            if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Power) { str2 = "使用"; sx = " W"; }
                            if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Fan) { str2 = "风扇"; sx = " RPM"; }
                            s_info  = "******"   str2   ":"   computer.Hardware[i].Sensors[j].Name   ":"   computer.Hardware[i].Sensors[j].Value.ToString()   sx   "\r";
                        }
                    }
                }
            }

资源截图

代码片段和文件信息

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    2634900  2017-05-17 23:24  DLL源码(全源码和官方Demo).rar

     文件     146545  2017-05-17 23:23  硬件风扇温度检测实例应用.rar

----------- ---------  ---------- -----  ----

              2781445                    2


评论

共有 条评论