Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have a universal app that uses PlayReady DRM protected videos. The problem with PlayReady is that it only work if the application build architecture matches the CPU architecture (e.g: ARM build on ARM, x64 on 64bit CPU, x86 on 32bit CPU). This is by design (for some reason).

So the problem is, if a user has a 64bit CPU and runs a 32bit 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. 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? There is nothing like System.Environment.Is64BitOperatingSystem from the full .NET.

like image 264
Igor Kulman Avatar asked Apr 21 '15 12:04

Igor Kulman


1 Answers

You are allowed to P/Invoke Win32's GetNativeSystemInfo in Windows Store apps (more info on the P/Invoke signature here); 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.

like image 187
Solal Pirelli Avatar answered Sep 19 '22 20:09

Solal Pirelli