>>>I want to try out this API function:
>>>
>>>ULONG WINAPI GetAdaptersAddresses(
>>> _In_ ULONG Family,
>>> _In_ ULONG Flags,
>>> _In_ PVOID Reserved,
>>> _Inout_ PIP_ADAPTER_ADDRESSES AdapterAddresses,
>>> _Inout_ PULONG SizePointer
>>>);
>>>
>>>How do I use that in VFP?
>>>
>>>See
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365915(v=vs.85).aspx for more detail
>>
>>If restricted to Vista and upwards, you may consider this alternative:
>>
>>
>>CLEAR
>>
>>LOCAL WMIService, AllNetworkAdapters, NetworkAdapter, MACAddress
>>
>>m.WMIService = GETOBJECT("winmgmts:\\.\root\cimv2")
>>
>>m.AllNetworkAdapters = m.WMIService.ExecQuery("Select * from Win32_NetworkAdapter",,48)
>>
>>FOR EACH m.NetworkAdapter IN m.AllNetworkAdapters
>> m.MACAddress = m.NetworkAdapter.MACAddress
>> IF !ISNULL(m.MACAddress)
>> ? m.NetworkAdapter.name + ": " + m.MACAddress + " (" + IIF(m.NetworkAdapter.PhysicalAdapter,"","not ") + "physical)"
>> ENDIF
>>ENDFOR
>>
>>
>>Complete set of properties at
https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx>
>Antonio,
>
>thanks for pointing me in this direction. I am trying it out and am adjusting the code you provided to return all the physical MAC addresses. Do you know if they will always be returned in the same order (I am concatenating them into a string and would need them to always be in the same position in the string)?
No, Frank, there is no guarantee that the order of adapters remain the same between different calls. WQL, the query language that interrogates WMI data, does not support the ORDER BY clause, so you must sort the addresses after fetching them (with ASORT(), for instance).
----------------------------------
António Tavares Lopes