|Date:||April 10, 2007 / year-entry #124|
|Summary:||The general rule with Windows header files is that if you don't specify which version of the header file you want, you get the latest version. For example, if you have the Windows XP Platform SDK header files and you #include |
The general rule with Windows header files is that if you don't
specify which version of the header file you want,
you get the latest version.
For example, if you have the Windows XP Platform SDK header files
If you call a function that is new for Windows XP, then your program won't run on earlier versions of Windows because the import can't be resolved.†
If you use a structure that changed for Windows XP, then your program won't run on earlier versions of Windows because the structure size will be wrong.
Even if the structure size didn't change, using a flag that was introduced in Windows XP will create difficulties for your program when run on earlier versions of Windows because those earlier versions don't support the flag you're passing. Depending on how the function in question was written, it may ignore the "flag from the future" or it may reject it as invalid.
If you want your program to run on older versions of Windows,
you have a few options.
First, you can explicitly "downgrade" your header file by
defining an appropriate symbol or symbols before including
#define WINVER 0x0400 #define _WIN32_WINNT 0x0400 #define _WIN32_WINDOWS 0x0400 #define _WIN32_IE 0x0400 #include <windows.h> #include <commctrl.h> #include <shlobj.h> ...
Oh yuck, now we have the messy world of
"So what's the difference between
†That statement is from the operating system's‡ point of view. You can of course use techniques like Visual Studio linker's delay-load feature to avoid creating an import dependency, but that's outside the operating system.‡
‡s/operating system/Windows operating system/
<-- Back to Old New Thing Archive Index