zoukankan      html  css  js  c++  java
  • 获取本地计算机的主机信息

    #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);
  • 相关阅读:
    实习项目1.
    try catch finally的用法
    asp.net 验证控件
    数据库操作语言
    webform Response的一些成员
    jQuery
    C#@的用法
    SQL分页查询
    抽象类与接口的区别
    抽象类与接口
  • 原文地址:https://www.cnblogs.com/liaocheng/p/4243482.html
Copyright © 2011-2022 走看看