简体   繁体   English

在Universal App(Windows)中检测CPU是否为64位

[英]Detecting if CPU is 64bit in Universal App (Windows)

I have a universal app that uses PlayReady DRM protected videos. 我有一个使用PlayReady DRM保护的视频的通用应用程序。 The problem with PlayReady is that it only work if the application build architecture matches the CPU architecture (eg: ARM build on ARM, x64 on 64bit CPU, x86 on 32bit CPU). PlayReady的问题在于,只有在应用程序构建体系结构与CPU体系结构匹配时(例如,ARM在ARM上构建,64位CPU上的x64、32位CPU上的x86),它才起作用。 This is by design (for some reason). 这是设计使然(出于某种原因)。

So the problem is, if a user has a 64bit CPU and runs a 32bit OS. 所以问题是,如果用户拥有64位CPU并运行32位OS。 In this case, he gets the x86 build from the store (because of 32bit OS) but PlayReady will not work because of the 64bit CPI vs X86 build mismatch. 在这种情况下,他从商店中获得了x86版本(由于32位操作系统),但由于64位CPI与X86版本不匹配,因此PlayReady无法正常工作。 In this case, I want to display a message (instead of just failing to play the video). 在这种情况下,我想显示一条消息(而不只是失败地播放视频)。

I can detect easily detect x86 build (by adding a conditional symbol), but how do I detect if the CPU is 64bit? 我可以轻松检测x86构建(通过添加条件符号),但是如何检测CPU是否为64位? There is nothing like System.Environment.Is64BitOperatingSystem from the full .NET. 完整的.NET中没有类似System.Environment.Is64BitOperatingSystem东西。

You are allowed to P/Invoke Win32's GetNativeSystemInfo in Windows Store apps (more info on the P/Invoke signature here ); 您可以在Windows应用商店应用中P /调用Win32的GetNativeSystemInfo (有关P / Invoke签名的更多信息,请参见 此处 )。 it returns a structure that includes the processor architecture. 它返回一个包含处理器体系结构的结构。
I can't find any information about what it returns in an x86 Windows on x64 machine scenario, and I don't have such a machine on hand to test it, but it's worth a try. 在x64机器上的x86 Windows环境中,我找不到有关它返回的内容的任何信息,并且我手边没有这样的机器可以对其进行测试,但是值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM