请教,MFC怎样获取硬件信息,包括CPU,硬盘,网卡等。谢谢!

解决方案 »

  1.   

    1.wmi2. cmd  systeminfo 输出类似
    OS 名称:          Microsoft Windows XP Professional
    OS 版本:          5.1.2600 Service Pack 3 Build 2600
    OS 制造商:        Microsoft Corporation
    OS 配置:          独立工作站
    OS 构件类型:      Multiprocessor Free
    注册的所有人:     微软用户
    注册的组织:       微软公司
    产品 ID:          71481-610-8134005-21407
    初始安装日期:     2011-01-02, 21:50:55
    系统启动时间:     3 天 1 小时 11 分 8 秒
    系统制造商:       BIOSTAR Group
    系统型号:         H61MHB
    系统类型:         X86-based PC
    处理器:           安装了 1 个处理器。
                      [01]: x86 Family 6 Model 58 Stepping 9 GenuineIntel ~2594 Mhz
    BIOS 版本:        ALASKA - 1072009
    Windows 目录:     C:\WINDOWS
    系统目录:         C:\WINDOWS\system32
      

  2.   

    就是API函数的问题
      

  3.   

    可以通过WMI来获取~~
      

  4.   

    想知道,在win10下,怎么获取固态硬盘的ID?
      

  5.   

    请教smwhotjay:能不能说得详细点,谢谢了!
      

  6.   


    /******************************************************************
    * Function Name: GetLocalMac
    * Function: 获取本机MAC地址
    * Input Parameters: NULL
    * OutPut Parameters: NULL
    * Return Value: 本机MAC地址
    ********************************************************************/
    CString CFlyCheckImageApp::GetLocalMac()
    {
    CString strMacTemp; ULONG ulOutBufLen = sizeof(IP_ADAPTER_INFO);
    PIP_ADAPTER_INFO pAdapterInfo = (IP_ADAPTER_INFO*)malloc(sizeof(IP_ADAPTER_INFO));
    if(pAdapterInfo == NULL)
    return NULL;
    if(GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) 
    {
    free(pAdapterInfo);
    pAdapterInfo = (IP_ADAPTER_INFO *)malloc(ulOutBufLen);
    if (pAdapterInfo == NULL) 
    return NULL;
    } if(GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == NO_ERROR)
    {
    for(PIP_ADAPTER_INFO pAdapter = pAdapterInfo; pAdapter != NULL; pAdapter = pAdapter->Next)
    {
    // 确保是有线物理网卡 
    if(pAdapter->Type != MIB_IF_TYPE_ETHERNET || pAdapter->Type == 71 || strstr(pAdapter->Description,"Bluetooth") >0)
    continue;
    if(pAdapter->AddressLength != 6)
    continue;
    strMacTemp.Format("%02X:%02X:%02X:%02X:%02X:%02X",
    int (pAdapter->Address[0]),
    int (pAdapter->Address[1]),
    int (pAdapter->Address[2]),
    int (pAdapter->Address[3]),
    int (pAdapter->Address[4]),
    int (pAdapter->Address[5]));
    break;
    }
    }
    free(pAdapterInfo); return strMacTemp;
    }
      

  7.   

    char vendor_serialnumber[0x14] = { 0 };
    char* SoftAuther::GetCpuID()
    {
    std::array<int, 4> cpui;   
        __cpuid(cpui.data(), 0x0);    
        int nIds_ = cpui[0];
        std::vector<std::array<int, 4>> data_;  //保存遍历到的所有cpui的值    
        for (int i=0;i<=nIds_;++i)
        {
            __cpuidex(cpui.data(), i, 0);
            data_.push_back(cpui);
        }
        //reinterpret_cast<int*>(vendor) //*reinterpret_cast<int*>(vendor)
        //索引0 0+4 0+8的值构成了CPU芯片的名称
        char vendor[0x20] = { 0 };
        *reinterpret_cast<int*>(vendor) = data_[0][1];
        *reinterpret_cast<int*>(vendor + 4) = data_[0][3];
        *reinterpret_cast<int*>(vendor + 8) = data_[0][2];     
        std::string vendor_ = vendor;
        sprintf_s(vendor_serialnumber, sizeof(vendor_serialnumber), "%08X", data_[1][0]);
        return vendor_serialnumber;
    }
    获取cpuid
      

  8.   

    你想要的这些我刚做完,觉得有用可以看看https://blog.csdn.net/github_37567324
      

  9.   

    你想要的这些我刚做完,觉得有用可以看看https://blog.csdn.net/github_37567324