Home » Blog
date 20.Nov.2016

■ Convert win32 programs to UWP with Desktop Bridge

I am an old school win32 programmer (C++ with ATL COM) and have long stopped paying attention to microsoft's programming whims-du-jour (.NET/WPF/XAML/WinRT/UWP/...) that seem to be changing every year. I must grant it to MS that code I wrote back in 1999 for windows 98 still works on windows 10, but I will stick to HWNDs and message queues thank you very much!

Early this year I heard about Desktop bridge (aka project Centennial) that could convert a classic win32 program like xplorer² into UWP and got curious about it. Universal Windows Platform (UWP) is the latest incarnation of WinRT, originally introduced with windows 8 — where overlapping windows and clipboard sharing are considered luxuries. The lure from microsoft to developers like me was inclusion in the Windows App Store, so I decided to take it on as a marketing experiment for DeskRule.

A tool called Desktop App Converter will take a win32 installer and turn it into an APPX, which is the package people download from the Store. As long as your installer just copies files it is a very simple conversion, but that's only half of the story. If you want to charge money the Store forces you to drop your custom purchase schemes and use only Windows.Services.Store.xxx API, which is WinRT code. That part is quite hard for old dogs who can't tell their lambda expressions from async delegates.

Toolset to consume WinRT API from win32 C++

The minimum platform for converted desktop apps is windows 10 anniversary edition (build 10.0.14393.0). So you first need to download windows 10 SDK. The recommended development tool is Visual Studio 2015, but I have a problem with the licensing terms. I have an MSDN subscription now, but what about tomorrow? I'd much rather use an older version with a traditional unlock key.

After perusing store sample code, I quickly realized that my favorite 1-man-show developer environment (VS6 :) wouldn't cut it. Sometime ago I reluctantly installed Visual Studio 2010 which knows what a lambda expression is; but VS2010 was released before windows 8, so it is oblivious of WinRT. WRL and C++/CX support start with Visual Studio 2012.

Have a look at the graph. Visual studio got massive over time, and especially so after 2012 with the winRT stuff (~100x bigger than VS6!). Idiotically, VS 2012 and 2013 installers don't even allow you to choose the components you want, so you end up with unbelievable lard you'd never use in C++. (I have a 256GB SSD drive that after 4-5 virtual machines is getting dangerously low)

But last night I had a great idea. Keep the relatively lean VS2010 but use the compiler/linker from VS2013. Later versions of VS have an option for the compiler toolset to use, but for VS2010 you need to manually change the Executable directories (from VC++ directories property page).
visual studio installed size over time
To use the WRL stuff you must add the windows 10 SDK include paths to your project settings (UM, SHARED and WINRT include folders) and add RUNTIMEOBJECT.LIB to the linker dependencies. Finally the mongrel 2010/13 environment needs the /arch:SSE option to avoid some funny errors (error LNK2019: unresolved external symbol __dtol3 — eh?)

If you ever browsed the Microsoft Store, you'd be amazed by the poor standard and diversity of apps. It is our duty as old windows developer hands to add some quality programs to the Store, before Microsoft goes under — and all the desktop establishment with it. Will it work? Will the store fee of 30% be worth it? I will keep you posted!

Post a comment on this topic »

Share |

©2002-2016 ZABKAT LTD, all rights reserved | Privacy policy | Sitemap