Was forbidding desktop applications on Windows RT the correct move?

Every day, someone bugs me at work about the news reports relating to how the Surface RT was not the success Microsoft had hoped it would be.  And Asus had the same conclusion.   I tell them Surface RT was a great piece of hardware.  It had the misfortune of not being able to run desktop apps.

But what about if Windows RT (Windows ARM) had allowed desktop applications (that have been recompiled to use the ARM instruction set) to run instead of just the ones that Microsoft had allowed (i.e. Office, and several built in apps, such as notepad, calculator, and some remote debugging tools).

I’ve been following the threads on xda developers on how the digital signing of desktop apps was circumvented to allow desktop apps to bypass this check completely, and in effect, open it up for desktop development.

Apart from the exploit, how was this possible at a tools level?  Well, if we go back to //build (in 2011), and look at the Beta version of Visual Studio 2012, you’ll notice something interesting: a complete version of MFC for ARM (including static lib files).  You’ll also notice that several key Windows SDK libraries were excluded (such as common controls, etc), making these MFC libraries more difficult to take advantage of.

The question remains: why would they have included MFC if they hadn’t planned on allowing developers to make desktop apps targeting ARM? My theory is that the original plan was to allow development of desktop apps for ARM, but at some point it was decided that desktop apps should be controlled and their creation only made available to Microsoft themselves.  Hence, when the first developer preview came out at //build there were still remnants of the original plans.

After this first build, subsequent builds removed the MFC libraries that were included in that first Beta.

So coming back to the original question: was forbidding desktop apps on ARM the correct move? At the surface level (pardon the pun) it looks to be a good decision.  the WinRT (Metro) environment provided for store apps, is tightly controlled, and therefore can have a better impact on battery life, potential viruses, app revenue, etc.  But it does stifle competition.  Look at VLC for ARM right now.  They can’t make a desktop app so have been forced to go to kickstarter to fund a Windows 8 (Metro) version of their app.  It’s still under development due to the tight controls over which APIs are allowed in WinRT apps. It’ll be interesting to see when, if ever, they release something.

Imagine the ability to have Chrome or Firefox for your Surface RT? Good thing?  I’m not sure.  Or your favorite app, which only needs to be recompiled for ARM using Visual Studio, and released directly from the software developer rather than through the store.  Good thing?  Hmm, the pros and cons are hard to weigh.  If you are starting from a zero ecosystem and trying to build it up, maybe desktop apps would have been a good thing.  But on the other hand it might have caused developers to focus less on the Windows Store apps and more on their legacy desktop apps.

But judging from the developer buy-in for WinRT (Windows Store apps), it’s a moot point.  The fact is, there hasn’t been enough buy-in.  And this is the key to success of the ecosystem, having developers risk getting no revenue from a store app, vs continuing with their legacy desktop apps on Intel only.  If they had allowed desktop apps on ARM, it’s possible more of those developers would be more excited about Windows RT.

New in Windows 8.1 store apps: a way to separate your app from your resources

One of the biggest complaints about the Windows 8 Windows store app approach to dealing with localization (separate translations for each language you decide to support), was the inability to decouple the various localizations from the main app.

As I’ve talked about in previous blog posts, the satellite DLL approach to Windows desktop apps, is an excellent one that can be used successfully with a lot of manual work (and can be automated quite easily when targeting Vista and above platforms).  But in Windows 8 store apps, there was no real analogy to this.

Windows 8.1 introduces a new type of package, a resource package.  MSDN describes it well here, I’ll provide a brief summary:

A resource package is a subset of your app that is used to provide language, scale, and DirectX features.  When you deploy an app to a machine, the decision is made whether you need one or all of the resource packages.  The app package itself can be deployed to a user’s machine with none of the resource packages, one of them, or all of them, depending on the particular needs of that machine. This is great for 2 reasons: it potentially increases download speed and reduces disk space.

An app bundle manifest (.appxbundlemanifest) is what describes your app’s package and all its resource packages.

The great thing about this new system, is that Visual Studio 2013 automatically handles this for you (separates the resources into separate resource packages).

There is also a package API that allows you to get information about packages, and a sample has been prepared by Microsoft and is found here:


as well as another great sample that shows you how this resource package approach could be used in a game:


If you’re ok with targeting Windows 8.1 for a future Windows Store app (see previous blog posts on pros and cons of targeting Windows 8 vs Windows 8.1), this is an excellent new system that I believe will be a great boon for developers.

A note about Stroustrup’s The C++ Programming Language 4th Edition

As far as C++ books are concerned, this is the definitive reference, from the inventor of C++, Bjarne Stroustrup.  I grew up with his 2nd, 3rd, and Special Editions, and I highly recommend that you take a look at the 4th for its great C++11 content.

Now, I don’t recommend you buy it right away.  Yes, I know you may be surprised by that statement, but let me explain. Stroustrup is one of those authors that takes accuracy seriously.  Due to that, he tends to go through many “printings” of his books.   He makes changes (corrections) in each of these printings, based on reader feedback.

Take a look at the errata for his 3rd and special editions:


He went through 21 revisions of the 3rd edition, and 14 revisions of the special edition (which was basically a continuation of the 3rd edition, except in hard cover).  So a total of 35 different 3rd editions when you include the special editions (disclaimer: some of these overlapped, i.e. there were early special edition printings equivalent to 3rd editions in higher printings, but you get the idea)

Why am I mentioning this?  Because the 4th edition is very young.  He’s already up to the 3rd printing after a couple of months:


Also, complaints have been made about the flimsy (physical) nature of the original release of the 4th edition.  Yes, it’s a paperback.  However, it looks like Addison-Wesley has heard the complaints because a hardcover version of the book will be released on July 29th!

So I recommend you take a look at buying the hardcover version after a few months of revisions.  You’ll have the majority of “big” fixes, and then you can follow along the errata pages for future fixes.

How do you know what printing you’re going to get if you order from somewhere online?  It’s hard to know, you could get a very early one based on stock. But amazon tends to go through stock quickly.  Another thing you could do is to get one from your local bookseller, and take a look on the inside to see what printing you’re getting.

Porting Win32 code to 64 bit: watch out for pointers

During the porting of an application to 64 bit, I recently found out about a very interesting registry key value, that, when set, will force the Windows memory manager to give you a high address (greater than 32 bit).  This is useful if you’re dealing with a lot of code that may inadvertently store pointers in 32 bit values.  Normally you’d get a 32 bit pointer in a 64 bit program, unless you specifically ask for it using the MEM_TOP_DOWN flag for VirtualAlloc API, but there is a way to force this behavior upon all apps:

In your registry, under:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Memory Management

Just create a DWORD value named AllocationPreference and set it to hexadecimal value 100000.   (hex value 0x100000)

Even if you’ve been super careful writing code, for example, using DWORD_PTR instead of DWORD everywhere it matters, you’ll be surprised how quickly you’ll find previously hidden problems lurking in your code.  I recommend that this value be set on all of your QA team’s machines as well.    The site I link to above gives a great explanation as to what the key value actually does.  You can find more information from Microsoft about the value here:



Experimenting with Microsoft Applocale

A question was recently raised in one of Michael Kaplan’s blog entries: can you avoid the “Applocale is a temporary solution” message? Well, some have found out a way, by hacking the Applocale executable. Another way is to take advantage of the fact that Applocale is just another compatibility layer that has been installed in the system. All compatibility layers use an environment variable named __COMPAT_LAYER to activate themselves. So with Applocale, the compatibility layer is named ApplicationLocale. If we search google for ApplicationLocale and __COMPAT_LAYER then we see that others have already made the same discovery. Let’s try the following experiment:

create a batch file named apploc.bat

in it include the following:
set __COMPAT_LAYER=ApplicationLocale
set AppLocaleID=0408
start c:\myapp\myapp.exe

where c:\myapp\myapp.exe is the application you want to run in AppLocale

now, run the batch file, and notice that it runs the app in the locale you specified in AppLocaleID. An easy way to get around the limitation of AppLocale.

Important to note: you must actually have Applocale installed on the machine you try this on. It’s not a compatibility layer that is shipped with the operating system.

The other main benefit to this approach compared to using an Applocale shortcut is that you can avoid running as administrator the app that you’re trying to use Applocale with. In certain cases, running as administrator can disable functionality of your application such as OLE drag and drop.