我正在尝试在Windows通用应用中获取设备信息,但我无法找到哪些软件包提供了os版本,国家/地区代码和语言代码。
private void SetGeneratedFields()
{
_fields.objectType = "user";
if (String.IsNullOrWhiteSpace(_fields.userID))
{
_fields.userID = System.Guid.NewGuid().ToString();
}
_fields.sessionID = System.Guid.NewGuid().ToString();
var deviceInformation = new EasClientDeviceInformation();
_fields.appVersion = this.GetAppVersion();
_fields.operatingSystem = deviceInformation.OperatingSystem;
_fields.operatingSystemVersion = "?";
_fields.countryCode = "?";
_fields.languageCode = "?";
_fields.deviceType = deviceInformation.FriendlyName;
}
private string GetAppVersion()
{
string appVersion = string.Format("Version: {0}.{1}.{2}.{3}",
Package.Current.Id.Version.Major,
Package.Current.Id.Version.Minor,
Package.Current.Id.Version.Build,
Package.Current.Id.Version.Revision);
return appVersion;
}
答案 0 :(得分:1)
(尚未)获取操作系统版本。还有其他问题需要解决这个问题,而大多数答案归结为这是有道理的,因为只有8.1个设备运行Windows运行时代码。因此,如果您使用的是Windows运行时应用程序,则会自动知道这必须是8.1(这对于Windows Phone至少是这样)。我想微软会在Windows 10发布后为此添加API调用。
您可以获得如下语言和国家/地区代码:
// Returns the following format: en-US
var tag = Windows.Globalization.Language.CurrentInputMethodLanguageTag;