C# 在Windows通用应用程序中获取设备/操作系统版本和国家/地区/语言代码
我正在尝试在windows universal应用程序中获取设备信息,但在查找提供操作系统版本、国家代码和语言代码的软件包时遇到问题C# 在Windows通用应用程序中获取设备/操作系统版本和国家/地区/语言代码,c#,windows-phone-8.1,win-universal-app,C#,Windows Phone 8.1,Win Universal App,我正在尝试在windows universal应用程序中获取设备信息,但在查找提供操作系统版本、国家代码和语言代码的软件包时遇到问题 private void SetGeneratedFields() { _fields.objectType = "user"; if (String.IsNullOrWhiteSpace(_fields.userID)) { _fields.userID = System.Guid
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;
}
获取操作系统版本是不可能的(目前)。还有其他一些问题需要解决,大多数答案归结为这样一个事实:这是有意义的,因为只有8.1设备运行Windows运行时代码。因此,如果您使用的是Windows运行时应用程序,您会自动知道这必须是8.1(至少对于Windows Phone是如此)。我想微软会在Windows10发布后为此添加API调用 您可以获得如下语言和国家代码:
// Returns the following format: en-US
var tag = Windows.Globalization.Language.CurrentInputMethodLanguageTag;