1

I am writing the installer for a WEC7 application that runs on several devices, each with a different architecture and possibly even different OS versions. The application is, for historical reasons, written in C++. This means that the application is compiled for each OS/architecture version. The installer package has all versions as resouces. I just need to figure out which one to install. OS version can be had at System.Environment.OSVersion.Version.Major, but I can't tell the difference between ARM and x86 architectures.

Possible solutions I have run into included:

SYSTEM_INFO si;
GetSystemInfo(&si);
return si.wProcessorArchitecture;

However, that is C++ code and therefore suffers from the same issue, that is: two compiled versions (ARM & x86) and you have to know which to load... but that's why I want to run the code.

I have also investigated System.Management, but that is not available on WEC7 that I can find.

Any suggestions?

  • [Here](https://stackoverflow.com/a/16996176/369) is a disgusting hack that might work – Blorgbeard Nov 16 '17 at 17:11
  • Interesting hack. However, it assumes IE10 is available. Given my situation (embedded devices), I am reasonably sure that none of them have IE10 installed. Thank you for the pointer. – user8447050 Nov 16 '17 at 17:43

1 Answers1

0

You could always P/Invoke the GetSystemInfo call:

[DllImport("coredll.dll")]
public static extern void GetSystemInfo(out SystemInfo info);

public enum ProcessorArchitecture
{
    Intel = 0,
    Mips = 1,
    Shx = 4,
    Arm = 5,
    Unknown = 0xFFFF,
}

[StructLayout(LayoutKind.Sequential)]
public struct SystemInfo
{
    public ProcessorArchitecture ProcessorArchitecture;
    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;
}
Carsten Hansen
  • 1,508
  • 2
  • 21
  • 27