|A component of Microsoft Windows|
|Type||Application programming interface|
|Included with||Windows Server 2012, Windows 8, Windows RT, Windows 8.1, Windows Phone 8.1, Windows Server 2012 R2, Windows 10, Windows 10 Mobile, Windows Server 2016|
|Windows Store, Windows API|
WinRT is implemented in the programming language C++ and is object-oriented by design. Its predecessor, Windows API (Win32 API) is written mostly in the language C. It is an unmanaged code application programming interface (API) based on Component Object Model (COM) that allows interfacing from multiple languages, as does COM. However, the API definitions are stored in
.winmd files, which are encoded in ECMA 335 metadata format, which .NET Framework also uses with a few modifications.[unreliable source?] This common metadata format allows significantly less overhead when invoking WinRT from .NET applications, relative to P/Invoke, and much simpler syntax.[unreliable source?]
The new C++/CX (Component Extensions) language, which borrows some C++/CLI syntax, allows writing and consuming WinRT components with less glue code visible to the programmer, relative to classic COM programming in C++, and imposes fewer restrictions relative to C++/CLI on mixing types. The Component Extensions of C++/CX are recommended for use at the API-boundary only, not for other purposes. Regular C++ (with COM-specific discipline) can also be used to program with WinRT components, with the help of the Windows Runtime C++ Template Library (WRL), which is similar in purpose to what Active Template Library provides for COM.
WinRT applications run within a sandbox and need explicit user approval to access critical OS features and underlying hardware. File access is restricted to several predetermined locations, such as the directories Documents or Pictures.
WinRT applications for Windows RT, Windows 8 and beyond are packaged in the
.appx file format; based upon Open Packaging Conventions, it uses a ZIP format with added XML files. WinRT applications are distributed mostly through an application store named Windows Store, where WinRT software (termed Windows Store apps) can be downloaded and purchased by users. WinRT apps can only be sideloaded from outside Windows Store on Windows 8 or RT systems that are part of a Windows domain, or equipped with a special activation key obtained from Microsoft.
In a major departure from Win32 and similarly to .NET Framework 4.5, most APIs which are expected to take significant time to complete are implemented as asynchronous. The application dispatches the API call, which returns immediately, freeing the application to perform other tasks while waiting for results. The asynchronous model requires new programming language constructs (keyword
async and operator
await in C# and Visual Basic, class
task and method
.then in C++, which are provided by the WinRT software development kit (SDK), keyword
promise and function
catch used in exception handling. Parts of the API needing asynchronous access include on-screen messages and dialogs, file access, Internet connectivity, sockets, streams, devices and services, and calendar, contacts and appointments.
The metadata describes the code written for the WinRT platform. It defines a programming model that makes it possible to write object-oriented code that can be shared across programming languages, and enables services like reflection.
Herb Sutter, C++ expert at Microsoft, explained during his session on C++ at the 2011 Build conference that the WinRT metadata is CLI metadata. Native code (i.e., processor-specific machine code) cannot contain metadata and it is then stored in separate WINMD-files that can be reflected like ordinary CLI assemblies.
Because it is CLI metadata, code written in native WinRT languages can be used from managed CLI languages.
WinRT has a rich object-oriented class-based type system that is built on the metadata. It supports constructs with corresponding constructs in the .NET framework: classes, methods, properties, delegates, and events.
One of the major additions to WinRT relative to COM is the cross-application binary interface (ABI), .NET-style generics. In C++/CX these are declared using the keyword
generic with a syntax very similar to that of keyword
Classes that are compiled to target the WinRT are called WinRT components. They are classes that can be written in any supported language and for any supported platform. The key is the metadata. This metadata makes it possible to interface with the component from any other WinRT language. The runtime requires WinRT components that are built with .NET Framework to use the defined interface types or .NET type interfaces, which automatically map to the first named. Inheritance is as yet not supported in managed WinRT components, except for XAML classes.
In WinRT terminology, a language binding is termed a language projection.
Native C++ is a first-class citizen of the WinRT-platform. To use WinRT from C++ two supported options are available: WRL, an ATL-style template library, and C++/CX (C++ with Component Extensions) which resembles C++/CLI. Because of the internal consumption requirements at Microsoft, WRL is exception-free, meaning its return-value discipline is HRESULT-based just like that of COM. C++/CX on the other hand wraps-up calls to WinRT with code that does error checking and throws exceptions as appropriate.
C++/CX has several extensions that enable integration with the platform and its type system. The syntax resembles the one of C++/CLI although it produces native code and metadata that integrates with the runtime. For example, WinRT objects may be allocated with
ref new, which is the counterpart of
gcnew from C++/CLI. The hat operator
^ retains its meaning, however in the case where both the caller and callee are written in C++ and living in the same process, a hat reference is simply a pointer to a vptr to a virtual method table (vtable, VMT).
Along with C++/CX, relative to traditional C++ COM programming, are partial classes, again inspired by .NET. These allow instance XAML code to be translated into C++ code by tools, and then combined with human-written code to produce the complete class while allowing clean separation of the machine-generated and human-edited parts of a class implementation into different files.
WinRT is a native platform and supports any native C++ code. A C++ developer can reuse existing native C/C++ libraries with the only need to use the language extensions when writing code that is interfacing with the runtime.
Since October 2016, Microsoft offers on GitHub a standard C++ language projection named C++/WinRT. In C++/WinRT the Windows Runtime is implemented solely in header files, and allows developers to both author and consume Windows Runtime APIs using any standards-compliant C++ compiler without the need of any other language extensions. It does not rely on C++/CX code, with the result of producing smaller binaries and faster code.
The .NET Framework and the Common Language Runtime (CLR) are integrated into the WinRT as a subplatform. It has influenced and set the standards for the ecosystem through the metadata format and libraries. The CLR provides services like JIT-compilation code and garbage collection. WinRT applications using .NET languages use the new Windows Runtime XAML Framework, and are primarily written in C#, VB.NET, and for the first time for XAML, with native code using C++/CX. Although not yet officially supported, programs can also be written in other .NET languages.
Classes defined in WinRT components that are built in managed .NET languages must be declared as
sealed, so they cannot be derived from. However, non-sealed WinRT classes defined elsewhere can be inherited from in .NET, their virtual methods overridden, and so on; but the inherited managed class must still be sealed.
Members that interface with another language must have a signature with WinRT types or a managed type that is convertible to these.
WinRT comes with an application programming interface (API) in the form of a class library that exposes the features of Windows 8 for the developer, like its immersive interface API. It is accessible and consumable from any supported language.
The Windows Runtime classes is a set SDKs that provide access to all functionality from the XAML parser to the camera function. The SDKs are implemented as native C/C++ libraries (unmanaged).
The naming conventions for the components (classes and other members) in the API are heavily influenced by the .NET naming conventions which uses camel case (specifically PascalCase). Microsoft recommends users to follow these rules in case where no others are given.
Since Windows Runtime is projected to various languages, some restrictions on fundamental data types exist so as to host all such languages. Programmers must be careful with the behavior of those types when used with public access (for method parameters, method return values, properties, etc.).
Numbercan only represent up to 53 bits of precision.
nullbeing represented as a null object
addEventListenerfunction or setting
on<EventName>property is used to subscribe to events.
<Verb>[<Noun>]Async. For the full runtime library, all methods that have a chance to last longer than 50 ms are implemented as asynchronous methods only.
|Windows 8||Windows Runtime|
|Windows 10||Universal Windows Platform (UWP)|
Starting from Windows Phone 8 it is possible to develop apps using a version of the Windows Runtime called the Windows Phone Runtime (WPRT). Although WP8 brought limited support, the platform did eventually converge with Windows 8.1 in Windows Phone 8.1.
Windows Phone 8 has limited support for developing and consuming Windows Runtime components through Windows Phone Runtime. Many of the Windows Runtime APIs in Windows 8 that handle core operating system functions have been ported to Windows Phone 8. Support for developing native games using C++/CX and DirectX has been added, by request from the game development industry.
However, the Windows Phone XAML Framework is still based on the same Microsoft Silverlight framework, as in Windows Phone 7, for backward compatibility. Thus, as of 2016 , XAML development is impossible in C++/CX. Development using either HTML5 or WinJS is unsupported on Windows Phone 8.
The Windows Phone 8 Silverlight Framework has been updated.[when?] It can exploit some of the new features in the Windows Runtime.
To enable sideloading on a Windows 8 Enterprise computer that is not domain-joined or on any Windows® 8 Pro computer, you must use a sideloading product activation key. To enable sideloading on a Windows® RT device, you must use a sideloading product activation key. For more information about sideloading product activation keys, see Microsoft Volume Licensing.
Manage research, learning and skills at defaultLogic. Create an account using LinkedIn or facebook to manage and organize your Digital Marketing and Technology knowledge. defaultLogic works like a shopping cart for information -- helping you to save, discuss and share.Visit defaultLogic's partner sites below: