标签:str amp mac地址 ptr comment com adapter glob dfs
#include "iphlpapi.h" #pragma comment(lib, "iphlpapi.lib ")
CString ODFSDownLoadThread::GetMacAddress() { CString strMac; strMac.Format(_T("")); u_char pMac[6]; PIP_ADAPTER_INFO adp = NULL; ULONG uLong = 0; //为适配器申请内存 ::GetAdaptersInfo(adp, &uLong); adp = (PIP_ADAPTER_INFO)::GlobalAlloc(GPTR, uLong); //取得本地适配器结构信息 if (::GetAdaptersInfo(adp, &uLong) == ERROR_SUCCESS) { if (adp != NULL) { //strMacAdd.Format("%s",adp->Address); memcpy(pMac, adp->Address, 6); strMac.Format(_T("%02X-%02X-%02X-%02X-%02X-%02X"), pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5]); GlobalFree(adp); } } return strMac; }
标签:str amp mac地址 ptr comment com adapter glob dfs
原文地址:https://www.cnblogs.com/baldermurphy/p/9803260.html