C++ – Windows API commctrl.h using application doesn’t work on machines without the Platform SDK


I have written something that uses the following includes:

#include <math.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <commctrl.h>

This code works fine on 2 machines with the Platform SDK installed, but doesn't run (neither debug nor release versions) on clean installs of windows (VMs of course). It dies with the quite familiar:

C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe
C:\Documents and Settings\Someone\Desktop\DesktopRearranger.exe

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.


How can I make it run on clean installs? Which dll is it using which it can't find? My bet is on commctrl, but can someone enlighten me on why it's isn't with every windows?

Further more, if anyone has tips on how to debug such a thing, as my CPP is already rusty, as it seems 🙂

Edit – What worked for me is downloading the Redistributable for Visual Studio 2008. I don't think it's a good solution – downloading a 2MB file and an install to run a simple 11K tool. I think I'll change the code to use LoadLibrary to get the 2 or 3 functions I need from comctl32.dll. Thanks everyone 🙂

Best Solution

Use Dependency Walker. Download and install from http://www.dependencywalker.com/ (just unzip to install). Then load up your executable. The tool will highlight which DLL is missing. Then you can find the redistributable pack which you need to ship with your executable.

If you use VS2005, most cases will be covered by http://www.microsoft.com/downloads/details.aspx?FamilyId=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en which includes everything needed to run EXEs created with VS2005. Using depends.exe you may find a more lightweight solution, though.