Since at least Visual Studio 2012 Win32 C++ programs compiled by Visual Studio by default do not run on 32-bit Windows XP, unless the following Linker command line option is added:
Attempting to run a program compiled without this option on XP will result in “not a valid Win32 application” error
Some more info:
Windows XP Targeting with C++ with VS 2012
Without this option provided to linker the compiled EXE will only run on Windows Vista or later…
We can see the minimum subsystem version, which matches to OS version number in the executables header:
However there is also an additional difference, in the PE File Header. This would appear to be the time stamp, because these files were compiled at different times. This was confirmed using the free tool PEBrowse Professional 64 (Which can open x86 binaries) http://www.smidgeonsoft.prohosting.com/software.html
So I patch this to version suitable for XP (5.01) by changing the 06 00 00 to 05 00 01 in the file header in two locations (I am using free Hex Editor here http://www.hexedit.com/ ):
Ok the patched file works fine on Windows 8.1.
Now on Windows XP:
As expected, the EXE compiled for Vista subsystem fails with <EXE> is not a valid Win32 application
Our patched EXE launches on XP fine
It is likely additional patching would be required on more complex programs, but proves it may be possible in some cases to easily patch a binary to make it run on Windows XP if necessary.
But please…get rid of XP if you still use it :)