Just 2 cents:
(a) With applications I discovered the same problem as Abhishek (e.g. a
test app built in the XP build environment does not run on Windows
2000). My solution was to ditch WDK “build” and to use the VS6 “nmake”.
For very small test applications with one or two source files this is
probably easiest.
(b) Doron Holan showed a nice way to set the target OS version in the
“sources” file used by build.exe to compile your stuff.
Addind this one definition should be fairly easy.
The key is “the SOURCES file” (= one file used by build.exe),
not “your source files” (=possibly 100+ files).
(c) The BulkUsb (WDM) WDK sample demonstrates nicely the MSDN quote that
Abhishek referred to (please bear with me, even if this now applies to
driver level and not to an application):
You build the USB driver in the XP build environment – and it runs
without modification anywhere on Windows 2000, Windows XP, Windows 2003
Server and Windows Vista. The 64-bit compiles run on all 64-bit
platforms, too.
(It will actually not build in the Windows 2000 build environment.
Without giving you any reason, why, and also no other hint. You just
have to figure this one out.)
(d) You can get even more “legacy” OS support:
My driver needs to work on Windows ME and Windows 98, too (some
customers use our software in combination with a computer as a “black
box” system).
So I had to cater for Windows 98 and Windows ME, too:
-
Windows ME is very easy: here is just the ExFreePoolWithTag call
missing, so the redefinition of ExFreePool (bulkusb.h) has to be
“shielded” by something like “#ifdef BREAK_WIN98_WINME” -
Windows 98 is a bit trickier: two USBD functions were exported in a
wrong way by USBD.SYS(W98) and some NTOSKRNL functions do not exist.
The most reasonable way to cope with this is to write a lower driver
that implements the missing functions. Luckily you don’t need to do this
yourself:
Buy Walter Oney’s book (Programming the Windows Driver Model, 2nd Ed.),
get the ServicePacks from his web site, and use WDMSTUB.SYS and
USBD98.LIB. (And don’t forget to copy two #define lines from stddcls.h
to use renamed USBD functions that link with USBD98.LIB).
BTW, the missing calls on Win98 and WinME were discovered using
WDMCHECK.EXE (also by Walter Oney, free download).
You have to actually run this on a Windows 98 and Windows ME installation.
Cheers
-Hagen