热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

VC++如何监控cpufan转速?

主板IO用W83627THG,用VC如何取得CPU温度,系统温度,CPU风扇转速,VBat的电压.



主板IO用W83627THG,用VC如何取得CPU 温度,系统温度,CPU风扇转速,VBat的电压.






5 个解决方案





#1





some   website   FYI   

  http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2000/larry/finalasm.htm   

  http://www.sun.com/products-n-solutions/hardware/docs/html/816-2485-12/asm.html#57334   




#2





从下CPUID指令下可以得到:   

    1.   CPUID指令代码:   0a20f   

        例:   

          

            CPUID   MACRO   

                      dw   0a20fh   

            ENDM   

          

    2.   CPUID有效检测   

            如果程序可以改变EFLAGE(扩展标志字)的第21位,那么CPUID有效,   

            否则无效。   

            注:对于Cyrix的CPU,在打开其内部CPUID标志位之前,用此方法检测   

            无效。   

          例:   

              

              ...   

              pushfd   

              pop   eax                           

              mov   ecx,eax   

              xor   eax,200000h         ;强制扩展标志位第21位为1   

              push   eax   

              popfd   

              pushfd   

              pop   eax   

              xor   eax,ecx                 ;如果扩展标志位的第21位为1,那么   

              je   no_cpuid                 ;CPUID存在,否则不存在   

              jmp   have_cpuid   

              ...   

            

    3.   CPUID指令   

        (1)基本指令   

            1.第0号功能:   (EAX=0)   

            调用寄存器:   

                EAX=0   

            返回寄存器:   

              EAX=最大功能号   

              EBX:EDX:ECX=CPU厂商识别串   

            例:   

              

              ...   

              xor   eax,eax                   

              CPUID               

              cmp   ebx,"Genu"   

              jne   no_intel     

              cmp   edx,"ineI"   

              jne   no_intel   

              cmp   ecx,"ntel"   

              jne   no_intel   

              jmp   is_intel   

              ...   

              

            合并ebx,edc,ecx寄存器的值,如果为GenuineIntel,就是Intel的CPU   

    

            另:   

            AuthenticAMD   =>   AMD   

            CyrixInstead   =>   Cyrix,被VIA兼并了   

            NexGenDriven   =>   NextGen   

            RiseRiseRise   =>   Rise   

            UMC   UMC   UMC     =>   UMC   

            CentaurHauls   =>   IDT   

    

            2.第1号功能:   (EAX=1)   

            调用寄存器   

              EAX=1   

            返回寄存器   

              EAX=CPU说明   

                CPU说明(见附录1)   

                  

                    bit           内容   

                  0--3           节率   (stepping)   

                  4--7           型号   (model)   

                  8--11         家族   (family)   

                  

              EDX=特征标志字   

                

                  bit             内容                                                                   缩写   

                    0               FPU   On-chip                                                     FPU   

                    1               Virtual   Mode   Extension                               VME   

                    2               Debugging   Extension                                     DE   

                    3               Page   Size   Extension                                     PSE   

                    4               Time   Stamp   Counter                                       TSC   

                    5               RDMSR/WRMSR   Instructions   

                    6               Physical   Address   Extension                       PAE   

                    7               Machine   Check   Exception                             MCE   

                    8               CMPXCHG8B   Instruction   

                    9               On-chip   APIC   HardWare   

                    10             Undefined   

                    11             SYSENTER/SYSEXIT   Instructions   

                    12             Memory   Type   Range   Registers   

                    13             Page   Global   Enable                                       PGE   

                    14             Machine   Check   Architecture                       MCA   

                    15             Conditional   Move   Instruction                   CMI   

                    16             Page   Attribute   Table                                   PAT   

                    17--22     Undefined   

                    23             MMX   Instructions                                           MMX   

                    24             internet   Streaming   SIMD   Extensions       SSE   

                    25--31     Undefined   

                  






#3





  (2)扩展指令   

              1.第80000000号功能(EAX=80000000h)   

                  调用寄存器:   

                  EAX=80000000h   

                  返回寄存器:   

                  EBX,ECX,EDX=保留   

                  EAX=最大功能号   

    

              2.第80000001号功能   

                  调用寄存器:   

                  EAX=80000001h   

                  返回寄存器:   

                  EAX=CPU说明(见第1号功能)   

                  EDX=扩展特征标志字   

                    

                      EDX[0]   <-   FPU:     FPU   on   Chip   

                      EDX[1]   <-   VME:     Virtual   Mode   Extention   present   

                      EDX[2]   <-   DE:       Debbuging   Extentions   

                      EDX[3]   <-   PSE:     CPU   support     4MB   size   pages   

                      EDX[4]   <-   TSC:     TSC   present   (See   RDTSC   command)   

                      EDX[5]   <-   MSR:     CPU   have   K5   Compatible   MSRs   

                      EDX[6]   <-   0     (Reserved)   

                      EDX[7]   <-   MCE:     Machine   Check   exception   

                      EDX[8]   <-   CX8:     Support   CMPXCHG8B   instruction   

                      EDX[9]   <-   Reserved   

                      EDX[10]<-   Support   SYSCALL   and   SYSRET   instruction     (!!!)   

                      EDX[11,12]<-     reserved   

                      EDX[13]<-   PGE:     Page   Global   Feature   support   

                      EDX[14]<-   reserved   

                      EDX[15]<-   CMOV:   CPU   support   CMOV   instruction   

                      EDX[16]<-   FCMOV:   CPU   support   FP.   FCMOV         (!!!)   

                      EDX[22..16]   <-   Reserved   

                      EDX[23]   <-   MMX:   CPU   support   IA   MMX   

                      EDX[24]   <-   (Cyrix)   Cyrix   Extended   MMX   

                      EDX[30..24]   <-   Reserved   

                      EDX[31]   <-   AMD   3DNow!   

                  

  1.   Cyrix   

          厂商识别串:   "CyrixInstead"   

          CPU名称               家族                 型号   

          MediaGX                 4                       4             

          6x86                       5                       2           (特征标志字=0x1)   

          6x86L                     5                       2           (特征标志字=0x105)   

          GXm                         5                       4   

          6x86MX                   6                       0   

                      

  2.   NexGen   

          厂商识别串:   "NexGenDriven"   

          CPU名称               家族                 型号   

          Nx586                     5                       

    

  3.   UMC   

          厂商识别串:   "UMC   UMC   UMC   "   

          CPU名称               家族                 型号   

          U5D                         4                       1   

          U5S                         4                       2   

    

  4.   AMD   

          厂商识别串:   "AuthenticAMD"   

          CPU名称               家族                 型号   

        486DX2WT                 4                         3   

        486DX2WB                 4                         7   

        486DX4WT                 4                         8   

        486DX4WB                 4                         9   

        5x86WT                     4                       0x0e   

        5x86WB                     4                       0x0f   

        486                           4                       Others   

        K5/SS                       5                         0   

        K5                             5                       1,2,3   

        K6                             5                       6,7   

        K6-2                         5                         8   

        K6-III                     5                         9   

        K5/K6                       5                       Others   

        K7工程样本             6                         0   

        K7                             6                       Others   

    

  5.   IDT   

          厂商识别串:   "CentaurHauls"   

          CPU名称               家族                 型号   

        WinChip   C6             5                         4   

        WinChip   2               5                         8   

    

  6     Rise   

          厂商识别串:   "RiseRiseRise"   

          CPU名称               家族                 型号   

          mP6                         5                       0   

    

  7.   Intel   

          厂商识别串:   "GenuineIntel"   

          CPU名称                                               家族                 型号   

          PentiumII                                             6                       3   

          Celeron                                                 6                       5   

          CeleronA                                               6                       6   

          PentiumIII                                           6                       7   

          PentiumPro   OverDrive   P6                 6                       1   

          PentiumPro                                           6                     Others   

          PentiumP5                                             5                       1   

          PentiumP54C                                         5                       2   

          Pentiumi486                                         5                       3   

          PentiumMMX                                           5                       4   

          PentiumDX4                                           5                       5   

          Pentium   OverDrive   P5                       5                       6   

          Pentium                                                 5                     Others   

          486DX                                                     4                     0,1   

          486SX                                                     4                       2   

          486DX2                                                   4                       3   

          486SL                                                     4                       4   

          486SX2                                                   4                       5   

          486DX2_WB                                             4                       7   

          486DX4                                                   4                       8   

          Celeron                                             7,8                     1   

          Pentium   III   Xeon                           7,8                     3   

          Pentium   IV                                       7,8                     4   

          Pentium   III                                     7,8                     L2Cache<1024   

          Pentium   III   Xeon                           7,8                     other   

          Pentium   III   Xeon                           10($A)   

          Pentium   VI   or   Ithanium               15($F)   

    






#4





主板IO用W83627THG

-------------不同主板的CPU温度之类的信息放的位置都不一样,也没有一个统一的标准。因此通过WinIO这样的方式取有可能就取不到。



除了上面的方法,在Windows下可以使用WMI来获取CPU温度等。你可以到网上搜一下“C语言 WMI”相关的东西,WMI非常强大,可以获得很多系统信息。

WMI中的Win32_Fan可获取风扇转速、Win32_Temperature可获取CPU温度。




#5





关于WMI中的Win32_Fan等的信息还可以参考这二个网页:

http://www.cppfans.com/articles/system/bcb_wmi.asp

http://hi.baidu.com/cnsdnet/blog/item/9386fc50ccf874581038c2bd.html









推荐阅读
author-avatar
福州-台江_616
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有