使用 WinRT 检索设备的序列号 [英] Retrieving the serial number of a device using WinRT

查看:32
本文介绍了使用 WinRT 检索设备的序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一款应用,它需要知道正在运行的设备的序列号.该应用程序适用于一家保险公司,用户可以通过该公司直接为设备购买保险.对于保险单,需要序列号.是否可以使用 WinRT 或任何可在 Metro 风格应用中使用的 API 检索设备的序列号?

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?

推荐答案

我不知道它是否完全符合您的需要,但可以唯一标识设备(自 Windows 8 RTM 起).

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

这篇关于使用 WinRT 检索设备的序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆