问题
How to get the unique Device in Windows Store App (Metro App)?
Can we use:
Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
Windows.System.Profile.HardwareToken hToke = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
IBuffer hardwareId = hToke.Id;
IBuffer signature = hToke.Signature;
IBuffer certificate = hToke.Certificate;
DataReader reader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] ar = new Byte[hardwareId.Length];
reader.ReadBytes(ar);
string i = ar.ToString();
string id = System.Text.Encoding.Unicode.GetString(ar, 0, ar.Length);
System.Diagnostics.Debug.WriteLine("ID" + Convert.ToBase64String(ar));
Network adapter Id of first Network adapter found
IReadOnlyCollection<Windows.Networking.Connectivity.ConnectionProfile> profiles =
Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
Windows.Networking.Connectivity.NetworkAdapter na = profiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;
string nid = na.NetworkAdapterId.ToString();
回答1:
Yes, this is a suggested way:
private string GetHardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Or, you have problems with this method?
回答2:
Here is an other way I found:
Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation deviceInfo =
new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
var myDeviceID = deviceInfo.Id;
来源:https://stackoverflow.com/questions/12893637/how-to-get-device-id-in-windows-8-metro-app