Can you use Windows 8 WinRT API from .NET Desktop applications?

Over the course of time I received a number of comments on my blog in this area. Many questions were asked like “Can you use WinRT from Desktop applications?”, “Can you use WinRT from .NET applications?”, etc..

Well, the answer is YES. It is possible to use WinRT from Desktop applications. WinRT APIs may be tied to Metro style apps, Desktop apps or potentially available to both. The documentation will list which environments (Desktop, Metro style or both) a given API works in.

Note: Custom WinRT components are only supported in Metro style applications. They are not supported in Desktop applications.

For ex, WinRT has an API for Accelerometer. The Accelerometer class represents an accelerometer sensor which returns G-force values with respect to the x, y, and z axes.

Namespace: Windows.Devices.Sensors namespace
Class: Accelerometer

If we open the API documentation at http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.sensors.accelerometer.aspx, see the section Applies to: Metro style apps | desktop apps. Which means this class works in Metro Apps as well as desktop apps.

image

Figure 1: MSDN documentation showing WinRT API and it’s applies to section.

Advertisements

2 thoughts on “Can you use Windows 8 WinRT API from .NET Desktop applications?

  1. Kushagra

    Hi! Thanks for your osom articles. In this article you have mentioned about the ‘applies to’ section which exists no more in the docs. Does that mean the WinRT API are not available in desktop mode apps anymore? Is is possible to make HTML5 desktop app using Accelerometer (for Intel )?

    Reply
    1. kishore1021 Post author

      Thanks. Ok, when I wrote the article, MSDN help documentation was still in beta. Now they have the actual release MSDN help version, which is different from the preview version.

      Now, to find out if a particular WinRT API can be used from .NET Desktop applications, go to the bottom of the MSDN page and see Requirements section and .observe the Minimum supported client heading. It lists down whether the WInRT API can be used in Windows Store apps and desktop apps or not.

      If you take the same Accelerometer MSDN help page, http://msdn.microsoft.com/en-us/library/windows/apps/windows.devices.sensors.accelerometer.aspx. Here is the information from Requirements section.

      Requirements

      Minimum supported client
      Windows 8 [Windows Store apps, desktop apps]

      Minimum supported server
      Windows Server 2012 [Windows Store apps, desktop apps]

      Minimum supported phone
      Windows Phone 8

      Namespace

      Windows.Devices.SensorsWindows::Devices::Sensors [C++]

      Metadata
      Windows.winmd

      Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s