问题
For statistic tracking, I'd like to be able to tell if the application is running on Windows RT or Windows Pro.
This thread says that there's no way to get the system version info:
Get OS-Version in WinRT Metro App C#
Any ideas?
回答1:
One thing you could do is to go to Configuration Manager in Visual Studio and instead of the default Any CPU configuration - create separate ARM/x86/x64 configurations and in project properties/Conditional compilation symbols define a symbol that is different for ARM vs. x86/x64 configurations. Then you can just test for it in your code using #if #else #endif preprocessor directives.
回答2:
Detect the architecture of the processor -- if x86/x64 it's not RT. If ARM it's RT.
Use the method here WinRT Replacement of System.Environment.TickCount
But instead of tick count look for the pertinent info.
回答3:
If you want actual processor information without creating multiple binaries check out this helper class I wrote https://github.com/AttackPattern/CSharpAnalytics/blob/master/Source/CSharpAnalytics/SystemInfo/WindowsStoreSystemInfo.cs
Then you can just write:
var cpu = WindowsStoreSystemInfo.GetProcessorArchitecture();
来源:https://stackoverflow.com/questions/13001208/detect-the-difference-between-winrt-and-windows-8