Archive for the ‘Windows Development’ Category

How to statically link the C++ REST SDK (Casablanca)

April 1, 2014 19 comments

You are trying to use the C++ REST SDK (Casablanca) in your Windows application. You have one of the following problems:

  • you need Windows XP support
  • when your code executes you receive a debug assertion: _pFirstBlock == pHead
  • you get unpredictable behaviour or random crashing
  • you need to build an application which links against static libraries

You have 30 minutes to solve the problem. Here is how:

The issue is that the C++ REST SDK only supports dynamic linking. The solution is to re-build the SDK with static linking. Read more…


Visual Studio 2013 Preview: Get rid of the all-caps menu bars

August 23, 2013 5 comments

I don’t believe it. The Visual Studio 2013 Preview build still uses all-caps menu bars.

That just won’t do. To eliminate this UI design monstrosity from your desktop, open Windows PowerShell (if you don’t know how to do this, open a command prompt, type powershell and press Enter), and type:

Set-ItemProperty -Path HKCU:\Software\Microsoft\VisualStudio\12.0\General -Name SuppressUppercaseConversion -Type DWord -Value 1

(all on one line)

Then restart Visual Studio. Your menus will no longer be shouting at you.

You’re welcome.


Visual Studio 2012 – Day 1 Annoyances (with an emphasis on C++)

February 19, 2013 3 comments

Update 21st February 2013: added information about Update 2, the C++11 Compiler November 2012 CTP (in two sections) and Find & Replace

Update 16th April 2013: the final version of Update 2 is now released; Update 1 is no longer needed (article updated)

So this is it, huh folks? 16 years of development, and the latest incarnation of the de-facto standard Windows development tool has an interface that might as well be from 1997. The compiler is not much better either it seems, as this C++11 feature support comparison shows: Visual Studio 2012 fails to include such basic support as initializer lists*, uniform initialization*, default and deleted constructors, inherited constructors and non-static data member initializers, while just about managing to shoehorn in raw string literals in the Update 1 package. Yet strangely, Microsoft managed to find time to implement SCARY iterators, checked iterators and futures and promises. SCARY iterators were only an optional part of the ratified C++11 standard.

But, the purpose of this article is to get your life in Visual Studio 2012 running smoothly, so let’s start with the basics.

* these features and others were added in the C++11 Compiler November 2012 CTP, see below Read more…

Deployment with IExpress: How to turn your MSI file into an EXE

September 22, 2012 3 comments

I have no problem with MSI file downloads. They are as simple as running an EXE. However, for reasons unknown, a lot of people don’t seem to like or understand downloading and running an MSI file; they feel more comfortable with EXEs. Visual Studio Setup projects turn your application into an MSI and a setup.exe file, which is inconvenient for distribution as generally online we want to provide the user with a single file download. Luckily there is a simple and free solution at hand in the guise of a quirky and little-known application included even as late as the Windows 7 base distribution called IExpress. This tool was originally created to enable branded deployments of Internet Explorer 6 (shocking, I know), but we can subvert it quite easily to our needs.
Read more…

How to determine programmatically whether your application and OS are 32 or 64-bit

September 22, 2012 1 comment

First of all, we must clear up a misconception. Some people want to programmatically determine whether the underlying processor in use is 32 or 64 bit. This is a misnomer, as modern Intel and AMD processors can and do run in both 32 and 64 bit modes, in addition there are considerations of cache width, bus width and so on. There is no “true, pure” 64-bit processor, therefore trying to determine this information is non-sensical.

You can, however, determine if you are running a 32 or 64 bit Windows environment, and whether your application is built as a 32-bit or 64-bit executable. Obviously, you should know the latter at compile time, but it can occasionally be able to know at run time too. Here is the code:

Read more…

Categories: Windows Development Tags: , ,

How to determine programmatically if your processor has hyperthreading, SIMD and other processing capabilities with __cpuid

September 22, 2012 1 comment

One of the machine intrinsics in Visual Studio is the __cpuid function, which returns a 4-byte array containing various bit-wise information about the processor hardware capabilities.

While all the gruesome details can be found on MSDN’s __cpuid, __cpuindex page, here is the basic principle:

int cpuinfo[4];
__cpuid(cpuinfo, 1);

bool hasHT = (cpuinfo[3] & (1 << 28)) > 0;

std::cout << "Hyperthreading on CPU is " << (hasHT? "supported" : "not supported") << std::endl;

Read more…

%d bloggers like this: