Retrieving the serial number of a device using WinRT

女生的网名这么多〃 提交于 2019-12-24 04:49:30

问题


We are working on an app that needs to know the serial number of the device it is running on. The app is for an insurance company with which the user is able to directly get insurance for the device. For the insurance policy the serial number is needed. Is it possible to retrieve the serial number of the device using the WinRT or any API that can be used in a metro style app?


回答1:


I do not know if it exactly fits your need, but it is possible to uniquely identify a device (since Windows 8 RTM).

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);
}  


来源:https://stackoverflow.com/questions/12690006/retrieving-the-serial-number-of-a-device-using-winrt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!