その It's not an appropriate API, so I'll share the information.
When developing a universal Windows application for Windows 8.1 and Windows Phone 8.1, we would like to determine which platform is currently in use at runtime and separate the logic. Even if I look at MSDN, I can't find such an API.Is there a way to make it happen?
windows windows-store-apps
Use the Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation class.The code below tells you whether the platform you are running is WindowsPhone or not (Windows):
As written in C#, the same API is available from C++, Visual Basic, and JavaScript.
bool DetectIfRunningOnWindowsPhone()
{
varinfo=new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
return(info.OperatingSystem.Equals("WindowsPhone"))?true:false;
}
In addition to EasyClientDeviceInformation, other simple methods include:
Get the name of the assembly that contains the App class by reflection (the creator should be able to distinguish!)
Determine by the Windows.ApplicationModel.Store.CurrentApp.LinkUri property (=URI of the web page of the store where the app is located)
Get the name of the assembly that contains the App class by reflection (the creator should be able to distinguish!)
Determine by Windows.ApplicationModel.Store.CurrentApp.LinkUri property (=URI of the web page of the store where the app is located)
http://msdn.microsoft.com/ja-jp/library/windows/apps/dn609832.aspx#CrossPlatform
For Windows and Windows Phone projects, click Why don't you take advantage of the values defined as conditional compilation symbols?
public bool IsPhone = false; # if WINDOWS_PHONE_APP IsPhone = true; #endif
I don't use the API or anything, so I don't think it's good...
© 2024 OneMinuteCode. All rights reserved.