首页 > 代码库 > 获取本地计算机的主机信息
获取本地计算机的主机信息
#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个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。