How to get a Unique Identifier for a Device within Windows 10 Universal?

How to get a Unique Identifier for a Device within Windows 10 Universal?

In Windows 10 Universal, you can get a unique identifier for a device by using the HardwareIdentification class. The HardwareIdentification class provides a method called GetPackageSpecificToken which returns a unique identifier for the device.

Here's an example of how to use the HardwareIdentification class to get a unique identifier for a device:

using Windows.System.Profile; public static string GetDeviceId() { HardwareToken hardwareToken = HardwareIdentification.GetPackageSpecificToken(null); var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareToken.Id); byte[] bytes = new byte[hardwareToken.Id.Length]; dataReader.ReadBytes(bytes); return BitConverter.ToString(bytes); } 

In this example, we're using the HardwareIdentification.GetPackageSpecificToken method to get a hardware token for the device. We then create a DataReader from the token's Id property and read the bytes into a byte array. Finally, we convert the byte array to a string using the BitConverter.ToString method.

The string returned by this method should be unique for each device and can be used as a device identifier. However, note that this identifier can change if the device undergoes hardware changes or the operating system is reinstalled.

Examples

  1. "UWP get Device Id"

    // Code var deviceId = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null).Id.ToString(); 

    Description: Retrieves the device identifier using the HardwareIdentification class in UWP.

  2. "UWP get Device Serial Number"

    // Code var serialNumber = Windows.System.Profile.SystemManufacturers.SystemEnclosure.SerialNumber; 

    Description: Retrieves the device serial number using the SystemEnclosure class in UWP.

  3. "UWP get Device Friendly Name"

    // Code var friendlyName = Windows.Networking.Proximity.PeerFinder.DisplayName; 

    Description: Retrieves the device's friendly name using the PeerFinder class in UWP.

  4. "UWP get Device MAC Address"

    // Code var networkInfo = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile().NetworkAdapter; var macAddress = networkInfo.GetPhysicalAddress().ToString(); 

    Description: Retrieves the device's MAC address using the NetworkInformation class in UWP.

  5. "UWP get Device Manufacturer"

    // Code var manufacturer = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceManufacturer; 

    Description: Retrieves the device manufacturer using the AnalyticsInfo class in UWP.

  6. "UWP get Device Model"

    // Code var model = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceModel; 

    Description: Retrieves the device model using the AnalyticsInfo class in UWP.

  7. "UWP get Device Unique Id"

    // Code var deviceId = Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation.Id.ToString(); 

    Description: Retrieves a unique identifier for the device using the EasClientDeviceInformation class in UWP.

  8. "UWP get Device Token"

    // Code var token = Windows.System.Profile.SystemIdentification.GetSystemIdForPublisher().Id.ToString(); 

    Description: Retrieves a unique token for the device using the SystemIdentification class in UWP.

  9. "UWP get Device User Id"

    // Code var userId = Windows.System.UserProfile.AdvertisingManager.AdvertisingId; 

    Description: Retrieves the device user's advertising identifier using the AdvertisingManager class in UWP.

  10. "UWP get Device Unique Id with additional info"

    // Code var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation(); var uniqueId = $"{deviceInfo.Id}-{deviceInfo.FriendlyName}-{deviceInfo.OperatingSystem}-{deviceInfo.SystemFirmwareVersion}"; 

    Description: Creates a unique identifier for the device using a combination of various device information properties. Adjust the properties based on your requirements.


More Tags

productivity-power-tools identify encode nsubstitute uipath machine-learning android-assets android-radiogroup rake-task macos-catalina

More C# Questions

More Various Measurements Units Calculators

More Housing Building Calculators

More Fitness Calculators

More Mortgage and Real Estate Calculators