So this is the first post that I’m writing in my brand new Windows 8 Developer Preview Samsung Tablet. One of the important concepts that have been introduced in the BUILD conference is the introduction of WinRT, the new runtime layer on top of which new apps can be written in the supported languages – .NET, JavaScript and C++.
WinRT exposes a set of libraries which can be used by any of the above languages. WinRT is supposedly the Win32 replacement, so it covers most of the more important capabilities Win32 covers. The main difference between the two is the way you access the API. WinRT exposes a set of classes, rather then functions in Win32, which you can access in an Object Oriented way in any of the supported languages. Each language got its own built in adapter layer for the WinRT API, so using classes from the WinRT layer is basically a matter of importing the correct namespaces.
One nice example of a WinRT class is the FileOpenPicker. It lives under Windows.Storage.Pickers namespace, and it’s practically the new way of opening files in Windows 8.

Another very nice thing you could do is create a custom WinRT library in one language and reference it in project created in another language. So you can import a project written in C++ for example and reference it in a .NET project. One would argue that this could be done years ago using COM, but in fact with WinRT this process is so much simpler.
All you need to do in the exported project is change the project output type to WinRT (in project properties) and follow the following guidelines:
- API signatures must only use Windows Runtime Types
- Structs can only have public data fields
- Inheritance can only be used for XAML controls, all other types must be sealed
- Only supports system provided generic types
I hope to try and cover some more of the built in WinRT libraries in the next posts.