Created
March 16, 2019 04:31
-
-
Save pnp0a03/3af5127162b5f9816e9098d8f702e88f to your computer and use it in GitHub Desktop.
Using GetNativeSystemInfo from UWP app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DllImport("api-ms-win-core-sysinfo-l1-2-3.dll")] | |
static extern void GetNativeSystemInfo(ref SYSTEM_INFO lpSystemInfo); | |
[StructLayout(LayoutKind.Sequential)] | |
public struct SYSTEM_INFO | |
{ | |
public ushort processorArchitecture; | |
ushort reserved; | |
public uint pageSize; | |
public IntPtr minimumApplicationAddress; | |
public IntPtr maximumApplicationAddress; | |
public IntPtr activeProcessorMask; | |
public uint numberOfProcessors; | |
public uint processorType; | |
public uint allocationGranularity; | |
public ushort processorLevel; | |
public ushort processorRevision; | |
} | |
... | |
var si = new SYSTEM_INFO(); | |
GetNativeSystemInfo(ref si); | |
Windows.System.ProcessorArchitecture at = (Windows.System.ProcessorArchitecture)si.processorArchitecture; | |
string architecture = at.ToString(); | |
if( 12 == (int)at) | |
{ | |
architecture = "Arm64"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment