Windows 8 で Device IDの取得


個体認識に使えるかな?

シミュレーターとローカルはもちろん同じID。

private string deviceUniqueId;
public string DeviceID
{
    get
    {
        if (deviceUniqueId == null)
        {
            var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
            var hardwareId = token.Id;
            var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);

            byte[] bytes = new byte[hardwareId.Length];
            dataReader.ReadBytes(bytes);

            deviceUniqueId = BitConverter.ToString(bytes).Replace("-", "");
        }
        return deviceUniqueId;
    }
}

Comments (0)

Skip to main content