是否有任何机制来唯一地识别设备(即使是匿名的)?
需要明确的是,通过“设备”我指的是电脑/平板/ PC。
的Windows 8.x的
http://codepaste.net/ybt893
string HardwareId()
{
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
视窗10
您必须添加移动和/或桌面扩展SDK。
string HardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
这样的能力,刚刚在Windows 8 RTM增加了:
Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null)
似乎没有要在Windows 8 Metro风格应用的便捷方式获得系统维护的唯一标识符,如提供其Windows Phone 7的Microsoft.Phone.Info.DeviceExtendedProperties.GetValue( "DeviceUniqueId" )
- http://social.msdn.microsoft.com/Forums/en-HK/winappswithcsharp/thread/62ac2a48-be60-465c-b3b7-bbb736a67a60
- http://social.msdn.microsoft.com/Forums/en-NZ/winappswithcsharp/thread/2ca0d5de-9db5-4349-839c-e01ff614ec6e
到目前为止,我已经找到了最好的解决办法是简单地生成一个新的GUID在应用程序的本地存储 ,并使用该标识来识别计算机为您的应用程序的当前和未来的发射。
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
Object value = localSettings.Values["uniqueDeviceId"];
if (!value)
{
value = Guid.NewGuid();
localSettings.Values["uniqueDeviceId"] = value;
}
请记住,用户可以删除本地存储,使你的应用忘记和重新生成值(或者甚至可能修改/恶搞的值),所以不要依赖于它的所有关键安全目的。 由于我只使用这种技术进行粗略统计和使用情况报告,这是好的适合我的需要。
难道这是作为登录的用户提供一致的ID?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.security.exchangeactivesyncprovisioning.easclientdeviceinformation.id.aspx
EasClientDeviceInformation.Id | id属性
返回本地计算机的标识符。 Id属性代表使用GUID设备ID从第一16个字节机号,用户SID,和应用程序ID的SHA256散列,其中机号使用本地用户组的SID的截断。 的GUID的每个部件以网络字节顺序返回。