Note that there are some explanatory texts on larger screens.

plurals
  1. POprogram crashes when i try find MAC address
    primarykey
    data
    text
    <p>i have a client server application in MFC using UDP where the server displays the IP address of connected clients in a listbox. If i run the client and server on the same computer the program displays the MAC address <strong>but if i try to run the client on a different computer the program crashes</strong>. Here are the 3 functions. I have an event handler for the listbox that displays the MAC address in a second listbox when an IP address is selected. PrintMACFromIP is the code for getting the MAC address</p> <pre><code>void CmfcServerDlg::OnLbnSelchangeListClientaddr() { BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH]; int nIndex = m_ClientAddrList.GetCurSel(); if(nIndex &lt; 0) return; CString s1; m_ClientAddrList.GetText(nIndex, s1); PrintMACFromIP(s1); } void CmfcServerDlg::PrintMACaddress(unsigned char MACData[]) { CString strText; strText.Format("%02X-%02X-%02X-%02X-%02X-%02X\n",MACData[0], MACData[1], MACData[2], MACData[3], MACData[4], MACData[5]); m_ClientIdList.AddString(strText); } void CmfcServerDlg:: PrintMACFromIP(const CString &amp;selected_ip_adr) { IP_ADAPTER_INFO AdapterInfo[16]; DWORD dwBufLen = sizeof(AdapterInfo); DWORD dwStatus = GetAdaptersInfo( AdapterInfo, &amp;dwBufLen); assert(dwStatus == ERROR_SUCCESS); PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; bool found = false; do { const IP_ADDR_STRING *addr_str = &amp;pAdapterInfo-&gt;IpAddressList; while(addr_str != NULL) { if(selected_ip_adr == addr_str-&gt;IpAddress.String) { found = true; break; } } if(found) { PrintMACaddress(pAdapterInfo-&gt;Address); break; } else { pAdapterInfo = pAdapterInfo-&gt;Next; } } while(pAdapterInfo); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload