Even though this capability does not exist in WinRT directly, it is possible to determine the processor architecture at runtime through the Win32 API, GetNativeSystemInfo. This API is included in the list of Win32 APIs that can be called from Windows Store apps (see the system page specifically). You can call this directly from a C++ app, of course, and from C# or Visual Basic you can use PInvoke as described on this MSDN forum thread.

To use the API from JavaScript, as with any other Win32 API, you’ll need to create a WinRT component wrapper. I show how to do this in Chapter 16 of my book, with the resulting DLL/WinMD being small. The short of it is that within your JavaScript app project, right click the solution in Visual Studio and select Add > New Project… then choose Visual C++ on the left and Windows Runtime Component in the middle. Call it SysInfo for lack of a better name.

In pch.h, add this line:


In the component’s header (.h) file, define a method like this:

namespace SysInfo
        static Platform::String^ GetProcessorArchitecture();


Here’s the implementation of the class in the .cpp file:


usingnamespace SysInfo;
usingnamespace Platform;


String^ Info::GetProcessorArchitecture(void)
    SYSTEM_INFO sysInfo;
    String^ str;


    switch (sysInfo.wProcessorArchitecture)
            str = “x64″; //AMD or Intel

            str = “ARM”;

            str = “IA64″;

            str = “x86″;

            str = “Unknown”;

return str;


To use the component from JavaScript, right click the JS project in Visual Studio and select Add Reference…. In that dialog select Solution on the left and the component name in the middle. Then you can use this line and do what you want with the resulting string.

var arch = SysInfo.Info.getProcessorArchitecture();

You could also return numeric codes from the C++ component, of course…your choice.



  1. Posted April 9, 2013 at 8:34 pm | Permalink

    This could also be implemented as a property and feel even more natural to call from JavaScript .

    • Posted April 10, 2013 at 4:46 pm | Permalink

      Definitely true…I guess my old C habits still like functions :)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>