0

I wanted to use the MAC Address of the device as a unique identifier, but this isn't exposed in the UWP API. The closest thing I can find is:

hostname.IPInformation.NetworkAdapter.NetworkAdapterId;

It seems to be the same value (after app restart and PC restart) but I don't know if it's robustly persistent. The docs don't seem to say, does anyone know what this ID actually consists of? Is it safe to use this as a reliable means of device identification?

If not, can someone recommend something?

Many thanks, Peter

LPLN
  • 475
  • 1
  • 6
  • 20
pma07pg
  • 516
  • 1
  • 4
  • 16
  • 2
    Such is the nature of UWP, one of its primary goals is to provide a secure environment that makes the user feel good about downloading executable files from the internet. [Existing backdoors](https://stackoverflow.com/questions/34097870/c-sharp-get-mac-address-in-universal-apps/34098615) prevents getting the app certified. – Hans Passant Dec 11 '19 at 14:18
  • This is perfect. Exactly what I need, as I'm not publishing to the store. If this works on the HL I'll add a comment. – pma07pg Dec 12 '19 at 06:54

1 Answers1

0

How is the NetworkAdapter.NetworkAdapterID generated in UWP

Derive from this case,

No, the NetworkAdapterId value is a GUID and has nothing to do with the machine MAC address. You cannot get the MAC adress of the computer through WinRT APIs exposed for the Windows Store application type.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • Not the same value as the MAC address, apologies if that was unclear. The value returned for NetworkAdapterId is the same each time. However, I want to know under what circumstances this ID would change and if it is a suitable candidate for unique device identifier. – pma07pg Dec 11 '19 at 13:43
  • Sorry guys, currently there is no document explaining it, Please try to add mobile network adapter to different computer if the id is same value, it may comes from mac address, if it is different, it may related with system. – Nico Zhu Dec 11 '19 at 13:49