最近突然明白,vc++原来是可以获取底层电脑配置信息的,因此,很激动。希望就这方面的问题获得论坛的支持。
比如获取cpu的信息,可以是这样的,
CString temp;
__asm{
xor eax,eax
cpuid
mov dword ptr vendor_id,ebx
mov dword ptr vendor_id[+4],edx
mov dword ptr vendor_id[+8],ecx
}
m_CPUID.Format("%s-",vendor_id);
__asm{
mov eax,01h
xor edx,edx
cpuid
mov s1,edx
mov s2,eax
}
temp.Format("%08X-%08X-",s1,s2);
__asm{

mov eax,03h
xor ecx,ecx
xor edx,edx
cpuid
mov s1,edx
mov s2,ecx
}
temp.Format("%08X-%08X\n",s1,s2);
据说可以实现,可是我根本就不懂上边的代码,希望可以给我解释一下,或者告诉我一方法弄懂他。谢谢
!

解决方案 »

  1.   

    cpuid那条汇编指令是关键。
      

  2.   

    /*CPUID指令代码:   0xA20F 上面调用功能号0,EBX:EDX:ECX返回的是CPU厂商名称~~~ EAX返回最大功能号 调用功能号1 asm   { 
        MOV   EAX,   0x1 
        CPUID 
    } EAX返回CPU说明信息 0--3位           节率   (stepping) 
    4--7位           型号   (model) 
    8--11位         家族   (family) EDX各位返回特征标志字 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             SSE2 
    26--31     Undefined 调用80000000号功能(EAX=0x80000000) 返回寄存器: 
    EAX返回最大功能号 调用功能号80000001 EAX返回CPU说明信息 0--3位           节率   (stepping) 
    4--7位           型号   (model) 
    8--11位         家族   (family) EDX各位返回特征标志字 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               Undefined 
    7               Machine   Check   Exception                             MCE 
    8               CMPXCHG8B   Instruction 
    9               Undefined 
    10             Support   SYSCALL   and   SYSRET   instruction 
    11--12     Undefined 
    13             Page   Global   Enable                                       PGE 
    14             Undefined 
    15             Conditional   Move   Instruction                   CMI 
    16--22     Undefined 
    23             MMX   Instructions                                           MMX 
    24             Cyrix   Extended   MMX 
    25--39     Undefined 
    30             AMD   3DNow   Plus 
    31             AMD   3DNow*/  
      

  3.   

    asm这个应该怎么学一下?现在在看一个linux系统的代码,但是这个似乎不是很懂!
      

  4.   

    __asm{}
    {}里面写汇编代码就行了
      

  5.   

    这是汇编方式,还可以用GetSystemInfo
      

  6.   

    不是说CPU ID 有些不提供了吗?