Archive for 7月 11th, 2016

WP8.1アプリでOSのバージョンを調べる。

月曜日, 7月 11th, 2016

WindowsPhoneのOSバージョンをどうやって調べるか?StackOverFlowにもあったのであるが?どうもうまくいかない。

ということで、いじくってみたら ScreenCapture Classが Win8.1で実装、そして Win10 Mobileで外されていることを発見、

じゃ、これを利用して、Win8.1/Win10Mobileの切り分けができるのではないかと思ったら、とりあえず、手持ちのデバイスやエミュレータは動いているので、公開することにした。

こんな感じ

	int WindowsPhoneOSVer = 81;//No Exception is WindowsPhone8.1
	try
	{	// Try Create ScreenCapture Class
		ScreenCapture ^TestScreenCap = Windows::Media::Capture::ScreenCapture::GetForCurrentView();
	}
	catch (Exception^ ex)
	{
		switch (ex->HResult)
		{
		case E_ACCESSDENIED:	//	WindowsPhone8.1
			WindowsPhoneOSVer = 81;
			break;

		case E_INVALIDARG:		//	Windows 10 Mobile is Not Supprt ScreenCapture
			WindowsPhoneOSVer = 100;
			break;
		}
	}

とりあえず、Lumia530/630/KATANA01や、Visual StudioのエミュレータではWin8.1/Win10 Mobileが切り分けられています。