Resources | Resources |



Finding the MAC Address

To retrieve the Media Access Control (MAC) address:
  1. Create an AEECLSID_WLANMACAddr object
  2. Call IItemStore_Get().

Example - Creating an instance of WLANMACAddr

Use the IShell create instance function.

nRet = ISHELL_CreateInstance(pMe->a.m_pIShell, 
                            (void **) &pStore);

Example - Get the MAC address

Use the IItemStore_Get() function to get the MAC address.

nRet = IItemStore_Get(pStore, szItemBuf, 32, &nItemLen);

Note: For AEECLSID_WLANMACAddr, IItemStore_Get() returns an array of bytes for the MAC address and sets nItemLen to the length of the MAC address + 1. The code below demonstrates a method to convert this MAC address into a string.

Example - Hex to string

The buffer returned by IItemStore_Get() must be turned into a string.

int I = 0;
szResult[0] = 0;
for (I = 0; I < nItemLen; I++)
    char szBytes[3];
    SPRINTF(szBytes, "%.2X", szItemBuf[i]);
    STRCAT(szResult, szBytes);
    if (i != nItemLen - 1)
        STRCAT(szResult, ":");
// you can now display the MAC address
WCM_DisplayMsg(pMe, "Found MAC Addr %s \n", szResult);