I believe that some API has changed or has been replaced with another API between Windows 7 and Windows XP. So my app which has been built on Windows 7, fails to load on Windows XP .
Is it possible that I can pass some flag to the Visual C/C++ compiler (Visual Studio 2008) or set some environment flag to tell Visual Studio to build my application for Windows XP while building on Windows 7?
One solution is to build it on Windows XP but that is something I want to avoid.
In your project properties, define preprocessor constants: WINVER=0x0501 and _WIN32_WINNT=0x0501. Or you can #define them in all header files, before you #include any of the standard headers.
See more information on MSDN (for some reason I cannot add direct link to MSDN here, but you should be able to search for it).