Carl
Carl

Reputation: 266

Reading device serial number and/or IMEI from UWP app

I am working on an app that will obtain an X.509 certificate for a device that will be used to encrypt various configuration data. Ideally, this certificate would contain information that can be correlated with procurement records. Is there any way to read the device serial number or IMEI from a universal windows app?

Upvotes: 4

Views: 3163

Answers (2)

Stefan
Stefan

Reputation: 17668

As for UWP in general, to get a system unique id (not IMEI), you might want to check out these classes:

Windows.System.Profile.SystemIdentification

and

Windows.System.Profile.HardwareIdentification

E.g.: you can query a unique device id with:

var buffer = SystemIdentification.GetSystemIdForPublisher();

Which has the following remarks according to msdn:

The ID has the following characteristics:

  • Unique for every system
  • Can be created offline
  • Persists across rebooting, OS upgrades/reinstalls, and so on
  • Persists across hardware modifications
  • Available in OneCore
  • Available on the factory floor for licensing purposes

https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.systemidentification.getsystemidforpublisher.aspx

Be aware that the return type is an IBuffer and produces some raw (non-string-like-readable) bytes so you might need to serialize that.

More info

https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.systemidentification.aspx

and

https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.hardwareidentification.aspx

Upvotes: 6

Rashwan L
Rashwan L

Reputation: 38833

It is not possible to get IMEI of another phone with phone number information, however you can get the device unique Id.

using Microsoft.Phone.Info;

object uniqueId;
var hexString = string.Empty;
if (DeviceExtendedProperties.TryGetValue("DeviceUniqueId", out uniqueId))
     hexString = BitConverter.ToString((byte[])uniqueId).Replace("-", string.Empty);
        MessageBox.Show("myDeviceID:" + hexString);

Reference

Upvotes: 1

Related Questions