C++/Get Mac Address Edit Diff Refresh Backlink Random Search History Help Setting Hide Show BOOL GetMacAddress(CStringArray& strMacArray, CString strSpecifiedIP) { PIP_ADAPTER_INFO pAdapterInfo; PIP_ADAPTER_INFO pAdapter = NULL; DWORD dwRetVal = 0; ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO); pAdapterInfo = new IP_ADAPTER_INFO[ulOutBufLen]; if (pAdapterInfo == NULL) return FALSE; if (GetAdaptersInfo(pAdapterInfo, &ulOutBufLen) == ERROR_BUFFER_OVERFLOW) { delete pAdapterInfo; pAdapterInfo = new IP_ADAPTER_INFO[ulOutBufLen]; if (pAdapterInfo == NULL) return FALSE; } if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == NO_ERROR) { pAdapter = pAdapterInfo; while (pAdapter) { CStringA strMacAddress; strMacAddress.Format("%02X:%02X:%02X:%02X:%02X:%02X", pAdapter->Address[0], pAdapter->Address[1], pAdapter->Address[2], pAdapter->Address[3], pAdapter->Address[4], pAdapter->Address[5]); CStringA strIPAddress; strIPAddress.Format("%s", pAdapter->IpAddressList.IpAddress.String); if(strSpecifiedIP.GetLength() > 0) { if(strIPAddress.Find(CT2A(strSpecifiedIP)) >= 0) { strMacArray.Add(CA2T(strMacAddress)); break; } } else strMacArray.Add(CA2T(strMacAddress)); pAdapter = pAdapter->Next; } } delete pAdapterInfo; pAdapterInfo = NULL; return TRUE; } 00:27:88:3C:9B:E3 MAC 이 글에는 0 개의 댓글이 있습니다. Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus