• 获取本地计算机的主机信息


    #include <afxcmn.h> // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT
     
    #include "IPhelper/Iphlpapi.h"
    #pragma comment(lib, "IPhelper/IPHLPAPI.LIB")
     
     
    DWORD dwLen = 0, dwError;
    dwError = GetAdaptersInfo(NULL, &dwLen);
    pIPHelper = (PIP_ADAPTER_INFO)malloc(dwLen);
    dwError = GetAdaptersInfo(pIPHelper, &dwLen);
     
    CString strMAC;
    strMAC.Format("%02X-%02X-%02X-%02X-%02X-%02X", pIPHelper->Address[0],
         pIPHelper->Address[1], pIPHelper->Address[2], pIPHelper->Address[3],
         pIPHelper->Address[4], pIPHelper->Address[5]);
    PIP_ADDR_STRING pAddrList = &pIPHelper->IpAddressList;
    CString m_IpAddress ="";
    while(pAddrList != NULL)
    {
      CString strAddr = pAddrList->IpAddress.String;
      pAddrList = pAddrList->Next;
      m_comAddr.AddString(strAddr);
     }
    CString strSubMask, strGateway;
    strSubMask.Format("%s", pIPHelper->IpAddressList.IpMask.String);
    strGateway.Format("%s", pIPHelper->GatewayList.IpAddress.String);
    m_strMac = strMAC;
    m_strSub = strSubMask;
    m_strGate = strGateway;
    m_comAddr.SetCurSel(0);
    free(pIPHelper);
  • 相关阅读:
    散列表
    5月19日
    5月17日阅读笔记3
    5月15日 阅读笔记2
    5月14日 阅读笔记1
    团队5
    团队博客2
    团队博客4
    团队博客3
    团队博客1
  • 原文地址:https://www.cnblogs.com/liaocheng/p/4243482.html
Copyright © 2020-2023  润新知