ChrisChuah 0 Posted November 24, 2023 (edited) Hi Is there a function in Indy whereby i could get the Mac address of the interface card? Or is there any function in Delphi whereby i could obtain the MAC address of the NIC card for FMX app? regards chris Edited November 24, 2023 by ChrisChuah Share this post Link to post
DelphiUdIT 176 Posted November 24, 2023 (edited) I don't know with Indy, but in Delphi there are the WinApi.IPHlpApi e WinAPi.IPTypes that are acquired from Project JEDI. You must enumerate the Interface cards and looks for properties: Uses WinAPi.IpHlpApi, WinApi.IpTypes; var NumInterfaces: Cardinal; AdapterInfo: array of TIpAdapterInfo; OutBufLen: ULONG; begin GetNumberOfInterfaces(NumInterfaces); SetLength(AdapterInfo, NumInterfaces); OutBufLen := NumInterfaces * SizeOf(TIpAdapterInfo); GetAdaptersInfo(@AdapterInfo[0], OutBufLen); for var i := 0 to NumInterfaces - 1 do begin (* These are the 6 bytes MAC Addresses of Interfaces AdapterInfo[i].Address[0], AdapterInfo[i].Address[1] AdapterInfo[i].Address[2], AdapterInfo[i].Address[3] AdapterInfo[i].Address[4], AdapterInfo[i].Address[5] *) end; end; EDIT: This works only in Windows platforms. Edited November 24, 2023 by DelphiUdIT Share this post Link to post
Remy Lebeau 1396 Posted November 24, 2023 (edited) 12 hours ago, ChrisChuah said: Is there a function in Indy whereby i could get the Mac address of the interface card? No. Indy does not operate at the ethernet layer, so it has no need for MAC addresses. 12 hours ago, ChrisChuah said: Or is there any function in Delphi whereby i could obtain the MAC address of the NIC card for FMX app? You will have to use platform-specific APIs, like GetAdaptersInfo()/GetAdaptersAddresses() on Windows, getifaddrs() on Posix, etc to get that kind of information directly from the OS. Edited November 24, 2023 by Remy Lebeau Share this post Link to post