Microsoft provides two models or frameworks for programming Windows 10 applications: Win32 and UWP (Universal Windows Platform). This post will look at some of the advantages and disadvantages of each framework.
- The most widely used framework. After all, it has been around in some form or other since the release of Windows 1.0 in 1985. If you have written Windows programs in C or C++, you have probably programmed at least one of them using the C Windows API or MFC.
- More applications have been written for Win32 than any other framework.
- There are a number of alternative toolkits for building Win32 applications that are cross-platform. Therefore, if you use one of these toolkits to build your application, you may be able to port it to other operating systems. See Adventures in Cross-Platform GUI Programming and Printing for some potential problem areas.
- Limited to Intel x86 and x64 architectures, so desktop and laptop computers only.
- The Win32 toolkits, including the cross-platform ones, were all started long before modern C++ (C++11 and later). They have kept their APIs to maintain backwards compatibility to previous versions of the toolkits, so if you use one of them, you will be doing a lot of C++98 programming.
- With the rise in popularity of the Internet, Win32 applications have become open to many security threats that can affect the entire computer system.
- Will not run on Windows 10 S. This may be a disadvantage if Windows 10 S systems become popular.
- Microsoft is trying to kill off Win32, though this will take many years to do.
UWP is the “modern” Windows API. It is implemented as a set of COM APIs. You do not (necessarily) reference these COM APIs directly, but rather through language specific projections.
- Applications can be programmed to run on desktops, laptops, tablets, XBox systems and HoloLens systems. You can include Windows phones as well, although they seem to be dying out.
- UWP applications are sandboxed, and therefore do not suffer from many of the security problems that Win32 apps do.
- Applications are Windows Store ready.
- Apps will run on Windows 10 S systems, which can load only UWP applications and only from Windows Store.
- This is the future of application development, at least as Microsoft sees it at the moment.
- This framework is relatively new, so you probably have a new toolkit to learn.
- Because this framework is relatively new, there are very few C++ toolkits available for developing GUI applications using C++.
- The most widely-used toolkit for C++ GUI programming of UWP applications (C++/CX) uses proprietary extensions to the C++ language (yuck!!!!). You are limited to using Visual C++ to build your applications.
- The Windows Runtime C++ Template Library (WRL) provides lower-level access than C++/CX to the UWP API, but at least you can code using standard C++ rather than rely on compiler extensions.
- There is a C++ header library (C++/WinRT) originally developed by Kenny Kerr to provide a C++ callable interface for UWP GUI programming. Kenny now works for Microsoft on the team that is continuing development of C++/WinRT. It only provides some of the functionality available in C++/CX, but work is continuing on providing additional functionality. The header library is available on GitHub; it is not included in the Windows 10 SDK or in Visual Studio.
- Alternatively, you could do the GUI programming in .Net languages and the rest of the programming in C++.
- There is currently no way, short of a complete rewrite of the application, to port a C++ UWP application to other operating systems.
This post has provided a look at developing applications in C++ for Windows 10. Specifically, it has documented a number of advantages and disadvantages of selecting either the Win32 or the UWP framework.
A few C++ GUI toolkits were mentioned in the various sections, above. The next post will look more closely at these and a number of other more popular C++ GUI toolkits for developing applications for Win32 and UWP.