Windows10 App2015. 7. 3. 10:58

윈도우 스토어앱에서는

 

그 흔한 Osversion 메소드를 지원하지 않는다 ㅡ.ㅡ;;;

 

system.environment.osversion

 

그래서 어떻게 해야 하나 찾아봤는데 역시 구글신이 해결해주었다.

 

 

핵심소스는 이부분이다.

 

 

public static async Task<string> GetWindowsVersionAsync()
{
// There is no good place to get this so we're going to use the most popular
// Microsoft driver version number from the device tree.
var requestedProperties = new[] { DeviceDriverVersionKey, DeviceDriverProviderKey };
var microsoftVersionedDevices = (await PnpObject.FindAllAsync(PnpObjectType.Device, requestedProperties, RootContainerQuery))
.Select(d => new { Provider = (string)d.Properties.GetValueOrDefault(DeviceDriverProviderKey),
Version = (string)d.Properties.GetValueOrDefault(DeviceDriverVersionKey) })
.Where(d => d.Provider == "Microsoft" && d.Version != null)
.ToList();
var versionNumbers = microsoftVersionedDevices
.GroupBy(d => d.Version.Substring(0, d.Version.IndexOf('.', d.Version.IndexOf('.') + 1)))
.OrderByDescending(d => d.Count())
.ToList();
var confidence = (versionNumbers[0].Count() * 100 / microsoftVersionedDevices.Count);
return versionNumbers.Count > 0 ? versionNumbers[0].Key : "";
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

참고 :  http://stackoverflow.com/questions/10125324/get-os-version-in-winrt-metro-app-c-sharp

'Windows10 App' 카테고리의 다른 글

UWP(윈도우 유니버설 응용 프로그램)  (0) 2016.10.24
Posted by 동동(이재동)