Share via


_NT_TARGET_VERSION

Use the _NT_TARGET_VERSION macro in your Sources or Makefile file to direct the Build utility to build your driver or sample for specific versions of the Windows operating system.

The following table shows the constants and values that you can assign to the _NT_TARGET_VERSION macro.

Operating system Constant Value Windows Driver Kit (WDK)

Windows 7 and Windows Server 2008 R2

_NT_TARGET_VERSION_WIN7

0x601

Windows 7 WDK and later versions.

Windows Server 2008

_NT_TARGET_VERSION_LONGHORN

0x600

Windows Vista WDK and later versions.

Windows Vista

_NT_TARGET_VERSION_VISTA

0x600

Windows Vista WDK and later versions.

Windows Server 2003

_NT_TARGET_VERSION_WS03

0x502

Windows Vista WDK and later versions.

Windows XP

_NT_TARGET_VERSION_WINXP

0x501

Windows Vista WDK and later versions.

 

You can use the _NT_TARGET_VERSION_XXX constants to assign specific operating system versions to other variables, such as MINIMUM_NT_TARGET_VERSION and MAXIMUM_NT_TARGET_VERSION.

You can use the _NT_TARGET_VERSION macro in your Makefile file to create expressions that direct the Build utility to take conditional steps during the build process. For example, if the _NT_TARGET_VERSION variable is set to $(_NT_TARGET_VERSION_WINXP), the following fragment would generate a warning message during the build:

!IF DEFINED(_NT_TARGET_VERSION)
!  IF $(_NT_TARGET_VERSION) >= $(_NT_TARGET_VERSION_VISTA)
!    INCLUDE $(NTMAKEENV)\Makefile.def
!  ELSE
!    message BUILDMSG: Warning : The sample driver "$(MAKEDIR)" is not valid for the current OS target.
!  ENDIF
!ELSE
!  INCLUDE $(NTMAKEENV)\Makefile.def
!ENDIF

_NT_TARGET_VERSION will override the target OS build environment that is set through SetEnv.bat. For example, if you set the following in your Sources file:

_NT_TARGET_VERSION=0x501

you will build code for Windows XP regardless of the target OS build environment that you have set through SetEnv.bat.

For more information about Setenv.bat, see Using the SetEnv.bat Command-Line.

You can also use the MINIMUM_NT_TARGET_VERSION and the MAXIMUM_NT_TARGET_VERSION macros to prevent the Build utility from building the driver or sample for earlier or later versions of the operating system than is necessary.

See Also

MINIMUM_NT_TARGET_VERSION

MAXIMUM_NT_TARGET_VERSION

Using the SetEnv.bat Command-Line

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011