2

I need to get the MAC address in a Universal Windows Application. I searched for an equivalent code but I did not succeed. Could someone guide me how to do this?

Ricardo Souza.

  • This code worked for me on a UWP app: https://stackoverflow.com/questions/34097870/c-sharp-get-mac-address-in-universal-apps/34098615 – G Greene Aug 02 '19 at 21:31

1 Answers1

2

How to Get mac address in Universal Apps?

AFAIK, currently there is no API can get the local machine MAC address directly in UWP app. In Win32 application we use NetworkInterface.GetPhysicalAddress method which is currently not implemented in UWP. But it seems like it is plan to support UWP, details please reference this issue.

So, temporary for a workaround you may try to use the GetAdaptersAddresses method of PInvoke as @ChristophvanderFecht mentioned. For a sample about GetAdaptersAddress you may reference this thread.

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
  • Thanks for the feedback, I am new to using C #. I checked the two guidelines, which is how I am programming in C # the first example: GetAdapterAddress at "https://msdn.microsoft.com/en-us/library/windows/desktop/aa365915(v=vs.85).aspx" , It is in C ++ and I can not use it. Already the second example I could not understand how to fetch the MAC address. So I still do not know how to get MAC address for Universal Windows applications - Windows and Windows Phone. Thank you so much – Ricardo Souza Jun 12 '17 at 19:14
  • @RicardoSouza, the sample I linked is a completed sample, just copy the code snippet and run it locally. If you still cannot , please detail what you cannot understand. Additionally, please add @ for someone or someone will not see your comment. – Sunteen Wu Jun 16 '17 at 03:11