2013-04-05 168 views
2

我可以从WP8上的C++/CX代码获得device unique id(UDID)吗?或者如果我不做,我该怎么做?我已经尝试过使用DeviceExtendedProperties(它不起作用,可能它是.net只有类)。来自C++/CX的设备唯一ID

+0

你试过[GetNativeSystemInfo](http://msdn.microsoft.com/en-us/library/windows/apps/ms724340.aspx)吗? – 2013-04-06 17:27:00

+0

在手机8中,您是否可以访问此API? http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.profile.hardwareidentification – 2013-04-12 19:58:19

回答

0

您可以使用HardwareIdentification.GetPackageSpecificToken方法获取特定于您的应用的设备唯一ID。它有一些复杂性,因为ID的价值取决于许多系统因素,例如可用内存,连接的外围设备(认为蓝牙耳机),网络连接等 - 确保阅读链接的文档!对硬件ID can be found here的组件进行更深入的讨论。

该值对于您的应用程序和特定设备的组合而言是独一无二的,这对于应用程序开发目的来说可能足够了。

请注意,此API需要WP 8.1“Windows运行时”应用程序,WP8 Silverlight应用程序将无法使用该应用程序。

using namespace Windows::System::Profile; 

... 

IBuffer^ nonce = ...; // optional, see documentation 
HardwareToken^ hwid = HardwareIdentification::GetPackageSpecificToken(nonce); 

// HardwareToken has a few properties, but the one you're likely interested 
// in is HardwareToken. 
IBuffer^ id = hwid->Id;