Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Native Only Apps with VS Express for Win8

Posted by , 02 June 2012 · 3,636 views

visual studio
Microsoft say "Visual Studio Express 2012 for Windows 8 provides tools for Metro style app development. To create desktop apps, you need to use Visual Studio Professional 2012, or higher."

That isn't quite true. In fact, there's no quite about it. In the current RC version on MSDN, it's downright wrong, and simple to achieve too.

So how do you do it?

Before starting the IDE, navigate to
Open general_appcontainer.xml and find the line that contains <BoolProperty Name="WindowsAppContainer", and change the readonly property to false, from its default of true and save. You may need to save the modified file elsewhere and copy the file over the original depending on UAC and permission settings.

Open the IDE and create a Visual C++->Blank App (XAML) project

When created, you can delete almost all things it puts in there. The xaml files, the appxmanifest, the assets and common folders and if you don't need or want precompiled headers you can delete both pch files too.

Now, right click the project file and change these values:

Configuration Properties->General and switch Metro Style App to false.

And there you go! You can compile and debug native, WinRT-less apps using the old guard of WNDCLASSEX and GetModuleHandle type stuff from when men were men and women even moreso. You'll need to readd UNICODE, _UNICODE, _DEBUG/NDEBUG to the preprocessor directives if you need them, and re-enable pdb-generation and the subsystem type in the linker settings.

The only major downside is that the Win32 SDK that comes with this version is severely lacking many major things such as bits for the common controls and GDI32.lib etc. If you have an older SDK you can point it at though, it's isn't that bad. if you don't, you'll also have to remove the entries that aren't kernel32.lib and user32.lib in Linker->Input or generate lib files from the dlls using link.exe.

What does turning the Metro switch off do?

Unsets C/C++->General->Consume Windows Runtime Extensions (No)
This removes the dependency on vscorlib110.dll

Unsets the WINAPI_FAMILY define, which winapifamily.h defaults to WINAPI_FAMILY_DESKTOP_APP
This enables the functions marked in the SDK as being for desktop apps only (basically all the ones you're familiar with from Win32).

Unsets Linker->Windows Metadata->Generate Windows Metadata
Stops the generation of winmd files which have no purpose for non WinRT apps

Removes the non IDE Linker setting: /AppContainer
This turns off the new for Windows 8 IMAGE_DLLCHARACTERISTICS_APPCONTAINER flag in the Optional PE Header, and lowers the OS and Subsystem version of the generated exe down to 6.0 (Vista) levels (the default is 6.2 (Win 8))

And that's about it as important stuff goes. Deleting one character and changing three others has turned Microsoft from paragons of virtue, into rotten stinking liars.

If you're only interested in the updated C++ 11 toolchain, it's probably just easier to copy the VC\bin, VC\include and VC\lib directories and use them side by side with your current install of VS. The compiler binaries run on Vista+ as long as msvcr110.dll is in the path somewhere.

Interesting. Been wondering about this recently.

So there's a technical workaround in the RC, but what, if any, are the legal issues? Will we be free to sell/distribute such applications if they are built with the Express version as we currently are?
I've no idea. Past results are no guarantee of future performance and all that. From a EULA standpoint, they may forbid it but from a compiled exe somebody is selling, I don't see how you'd be able to tell if they were flouncing the rules or were legit. The C/C++ toolchain exes in the VS Ultimate RC are identical to the ones in the Express package, if that holds for release the only way they could influence the resulting binary (i.e. adding a 'This was made by express, you can't sell it' tag) would be via switches and those can be quite easily countermanded.
Out of interest, do you know that the toolchains really are identical in the Ultimate and Express editions?I believe there were a few differences in VS2010 such as profile-guided optimisation.
Unfortunate choice of words, I meant the basic cl, link, the dlls those require and the ms-name-110.dll's.

Express doesn't come with the PGO binaries, but it's not disabled. You can enable it in the linker property pages (since those are installed) which causes it to scan for the pgort110.dll. If it finds such a dll it'll happily use it but if it doesn't it'll tell you 'PGO is unavailable in this version'. I tried using the 2010 PGO binaries with a bit of renaming and symlink kerjiggering but it fails right at the death, so unless you get them from elsewhere and plug 'em in, its not available.

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

January 2017 »

15161718 19 2021