Skip to content

Windows programming

📘 Glossary

app model

App model is a term Microsoft began using after the release of UWP in 2012 to refer to the hosting model, or the rigidly defined parameters for how an application is installed, stores state, manages versions, and integrates with the operating system and other apps, that generally define an application lifecycle. Specifically, the term was used in the context of describing the security sandbox and other restrictions of the UWP app model for Microsoft Store applications.

Previous to UWP, there had been no definition of an "app model" per se and developers of a Win32 application were free to determine these parameters individually. This caused wide disparity in implementation among applications, resulting in registry bloat and poorly managed uninstallations. The UWP App Model was specifically introduced to answer these concerns which had plagued generations of Windows. (src)

The failure of UWP as an app model resulted in Project Reunion, an effort to reunify the bifurcated Windows development landscape.

C++/CX

C++/CX is a legacy language projection that uses nonstandard C++ (see C++/WinRT).

Compile a C++ to a DLL (src)

Invoke MSVC, creating:

  • Library.dll
  • Library.lib
  • Library.exp
  • Library.obj
cl /w4 /ld Library.cpp Library.def
#include "Library.h"
#include <stdio.h>

void Cluck()
{
    printf("C-style cluck!\n");
}
#pragma once

void Cluck();

A definitions file is broken into sections, all of which are optional.

EXPORTS

Cluck

Now the libary can be used in an application

cl /W4 Application.cpp /link Library.lib
#include "Library.h"

int main()
{
    Cluck();
}

C++/WinRT

C#/Win32

Resources:

C#/WinRT

.NET Core 3 and .NET Framework ("NETFX") applications can continue to use the Microsoft.Windows.SDK.Contracts NuGet package.

C#/WinRT is the WinRT language projection for C#, created after .NET5 removed WinRT projection support for C# out of the .NET compiler. This represents a decoupling of the Windows-specific APIs from .NET

It is used to create C# runtime components hosted in non-.NET languages by first building interop assemblies from Windows Metadata files using cswinrt.exe.

Resources:

COM

Component Object Model was developed in the late 1980s by Microsoft. The Component Object Model is a binary standard interface specification for objects. It originated in 1993 as a renaming of OLE (Object Linking and Embedding) 2.0, used by Microsoft Office at the time to link data between applications.

COM objects support a collection of interfaces, most importantly IUnknown which all COM objects must implement. IUnknown includes QueryInteface() which returns pointers to the other interfaces also implemented by the COM object. It also includes AddRef() and Release(), which manage the object's lifetime.

COM uses HRESULTs, 32-bit longs, to indicate success or failure. Bit 31 indicates success (0) or failure (1). With .NET interop, a failed HRESULT turns into a thrown COMException. Common HRESULTs include S_OK, S_FALSE, E_FAIL, and many other failure codes also beginning with E_.

COM objects are created by calling CoCreateInstance(). This function, which is stored in ole32.dll, searches the Registry for the given class ID, then loads the apropriate COM Server DLL file. This DLL file then creates a class factory which then creates the COM instance, which is passed back to the client as an interface pointer. (src)

COM classes must be registered in the Registry, at minimum by mapping the class ID (a GUID) to a DLL, in the HKEY_CLASSES_ROOT hive. This is done using the regsvr32.exe utility. (src)

Core application

Core application refers to the lifecycle of a UWP application, through which Windows offers app-specific services relating to power management, security, etc and abstracts the app itself. It offers a level of control over graphical applications comparable to that available for apps as services. (src)

DirectX

DirectX is a gaming API that was created by Eric Engstrom (d. 2020), Alex St. John, and Craig Eisler in 1994 to support game development on Windows 95.

Interop assembly

Interop assemblies allow .NET applications to call native code. They can be distributed along with applications that reference them.

Language projections like C#/WinRT produce interop assemblies composed in C# which can then be compiled into a projection assembly.

Language projection

A language projection (or simply "projection") is a native adapter that enables programming APIs in a way that is idiomatic to a given language.

Framework C# C++
WinRT C#/WinRT C++/WinRT
Win32 C#/Win32 ?

Resources:

TFM

Target Framework Monikers (TFM) are used in NuGet packages and project files to refer to the flavor of .NET targeted by an application.

Only for .NET5, Microsoft introduced new monikers that indicate the targeted OS after a hyphen, e.g. net5.0-windows, etc. These monikers will pull in the projection assemblies that are needed to access those APIs and replace earlier use of the Microsoft.Windows.SDK.Contracts package reference.

Example TMFs include:

  • net5.0-windows10.0.19041.0 Windows 10 version 2004
  • net5.0-windows10.0.18362.0 Windows 10 version 1903
  • net5.0-windows10.0.17763.0 Windows 10 version 1809

References:

UWP

Universal Windows Platform (UWP) refers to both a UI framework incorporating the Fluent Design System as well as an app model. When the UWP XAML framework was released in 2012, UWP was touted as a means to develop for many different device platforms, including mobile and tablet. Until recently, the UWP XAML framework was only available for applications using the UWP app model for apps destined for the Microsoft Store.

However, UWP development has floundered over the past half decade as Microsoft has been unable to produce sufficient interest in its mobile and tablet devices or the Microsoft Store. Microsoft itself has ceased development of UWP apps for Office or for Xbox, for which it has turned rather to Electron.

Win32

WinMD

Windows metadata files (*.winmd) are machine-readable files that define Windows Runtime APIs. All public types in a .winmd file must be WinRT types. They use the same physical file format as CLR assemblies.

Resources:

WinRT

The Windows Runtime is a framework introduced with Windows 8 to provide access to system resources. WinRT is separate from, although it is used by, .NET. Under the surface, WinRT is implemented as COM components.

UWP XAML controls were included in WinRT until recently when they were moved to the WinUI NuGet package.

Resources:

WinUI

Windows UI Library (WinUI) 3 is a native UI framework that represents a rebranding of the UWP UI framework, which had previously only been available for applications using the UWP app model, and a move to make it available for both app models.

Still in development, it promises to deliver a unified framework and all the styles and controls previously distributed in WinUI 2, which in turn is a NuGet packaging containing the UWP XAML controls and styles.

Unfortunately, because the UWP framework had been available only for the UWP app model, it did not experience wide adoption among developers who prefered the flexibility of the older Win32 "app model" (or rather, the lack of one).