Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to print the MAC address
    primarykey
    data
    text
    <p>i created a client server program that displays the MAC and ip addresses of the clients and i have a function that gets the MAC address of the computer but I'm having trouble printing the MAC address in a listbox. I created a print function that did work before but i changed the code for finding the mac address and now its not working (also i don't know if i'm calling printMACaddress in the right place). I have two list boxes - one displays the ip address the other displays the MAC address. When i click the ip address i want the MAC address of that computer to be displayed but right now its not displaying. nothing happens when i click the ip address</p> <pre><code> void CmfcServerDlg::OnLbnSelchangeListClientaddr() { bool GetMACFromIP(BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH], const std::string &amp;selected_ip_adr); } 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); } bool CmfcServerDlg::GetMACFromIP(BYTE Address[MAX_ADAPTER_ADDRESS_LENGTH], const std::string &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) { memcpy(Address, pAdapterInfo-&gt;Address, MAX_ADAPTER_ADDRESS_LENGTH); PrintMACaddress(pAdapterInfo-&gt;Address); //problem here break; } else { PrintMACaddress(pAdapterInfo-&gt;Address); pAdapterInfo = pAdapterInfo-&gt;Next; } } while(pAdapterInfo); return found; } </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    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