gpt4 book ai didi

c++ - 使用 C++ 代码获取 Windows Phone 8.1 中的唯一 DeviceId

转载 作者:行者123 更新时间:2023-11-30 02:40:42 25 4
gpt4 key购买 nike

我正在尝试使用 C++ 代码获取 Windows Phone 8.1 的唯一 44 位设备 ID。我已经点击了以下链接。

http://abundantcode.com/alternate-way-of-getting-the-unique-deviceid-in-windows-phone-8/#comment-85511

只有一行的短代码,

var UniqueID = Windows.Phone.System.Analytics.HostInformation.PublisherHostId;

但是我在上面遇到了很多错误。

error C3083: 'Analytics': the symbol to the left of a '::' must be a type , 
error C3083: 'HostInformation': the symbol to the left of a '::'must be a `type ,`
error C2039: 'PublisherHostId' : is not a member of'Windows::Phone::System' ,
error C2065: 'PublisherHostId' : undeclared identifier

我还定义了这里提到的 ID_CAP_IDENTIY_DEVICE 属性。

<Capability Name="ID_CAP_IDENTITY_DEVICE"/>

虽然我很困惑这是对还是错。

最佳答案

对于 Windows Phone 8.0,您可以使用 PublisherHostId,但对于 Windows Phone 8.1 native 代码项目,您需要使用 HardwareIdentification::GetPackageSpecificToken()又名 ASHWID

这样您就可以更轻松地与 Windows 8.1 共享代码。此 ID 对于给定设备上的给定应用程序是不变的,但会因应用程序和设备而异。

这是一个适用于 Windows Phone 8.1 的示例:

using namespace Windows::System::Profile;
using namespace Windows::Security::Cryptography;
using namespace Platform;

auto token = HardwareIdentification::GetPackageSpecificToken(nullptr);
Array<byte>^ buffer = ref new Array<byte>(token->Id->Length);

// Nothing to do with crypto; just a helpful class
// to convert IBuffer^ -> Array^
CryptographicBuffer::CopyToByteArray(token->Id, &buffer);

// Output the first four bytes of the key
char key[9];
sprintf_s(key, sizeof(key) / sizeof(key[0]), "%02X%02X%02X%02X",
buffer[0], buffer[1], buffer[2], buffer[3]);
OutputDebugStringA(key);

关于c++ - 使用 C++ 代码获取 Windows Phone 8.1 中的唯一 DeviceId,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28762808/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com