본문 바로가기

프로그래밍

WINVER or _WIN32_WINNT

Setting WINVER or _WIN32_WINNT

You can define these symbols by using the #define statement in each source file, or by specifying the /D compiler option supported by Visual C++.

For example, to set WINVER in your source file, use the following statement:

#define WINVER 0x0502

To set _WIN32_WINNT in your source file, use the following statement:

#define _WIN32_WINNT 0x0502

To set _WIN32_WINNT using the /D compiler option, use the following command:

cl -c -D_WIN32_WINNT=0x0502 source.cpp

For information on using the /D compiler option, see /D (preprocessor definitions).

Note that some features introduced in the latest version of Windows may be added to a service pack for a previous version of Windows. Therefore, to target a service pack, you may need to define _WIN32_WINNT with the value for the next major operating system release. For example, the GetDllDirectory function was introduced in Windows Server 2003 and is conditionally defined if _WIN32_WINNT is 0x0502 or greater. This function was also added to Windows XP with SP1. Therefore, if you were to define _WIN32_WINNT as 0x0501 to target Windows XP, you would miss features that are defined in Windows XP with SP1.


특정 버전 이상에서만 다르게 컴파일 할때

//InitializeCriticalSectionAndSpinCount 는  Server 2003 나 xp 이상부터 지원
#if (_WIN32_WINNT >=0x0501)
	::InitializeCriticalSectionAndSpinCount(&cs_, 4000);
#else
	::InitializeCriticalSection(&cs_);
#endif

버전정보

Minimum system requiredMacros to define
Windows Server 2003 family_WIN32_WINNT>=0x0502
Windows XP_WIN32_WINNT>=0x0501
Windows 2000_WIN32_WINNT>=0x0500
Windows NT 4.0_WIN32_WINNT>=0x0400
Windows Me_WIN32_WINDOWS=0x0490
Windows 98_WIN32_WINDOWS>=0x0410
Internet Explorer 6.0_WIN32_IE>=0x0600
Internet Explorer 5.01, 5.5_WIN32_IE>=0x0501
Internet Explorer 5.0, 5.0a, 5.0b_WIN32_IE>=0x0500
Internet Explorer 4.01_WIN32_IE>=0x0401
Internet Explorer 4.0_WIN32_IE>=0x0400
Internet Explorer 3.0, 3.01, 3.02_WIN32_IE>=0x0300

Minimum system requiredMinimum value for _WIN32_WINNT and WINVER
Windows 7_WIN32_WINNT_WIN7 (0x0601)
Windows Server 2008_WIN32_WINNT_WS08 (0x0600)
Windows Vista_WIN32_WINNT_VISTA (0x0600)
Windows Server 2003 with SP1, Windows XP with SP2_WIN32_WINNT_WS03 (0x0502)
Windows Server 2003, Windows XP_WIN32_WINNT_WINXP (0x0501)

Minimum version requiredMinimum value of _WIN32_IE
Internet Explorer 8.0_WIN32_IE_IE80 (0x0800)
Internet Explorer 7.0_WIN32_IE_IE70 (0x0700)
Internet Explorer 6.0 SP2_WIN32_IE_IE60SP2 (0x0603)
Internet Explorer 6.0 SP1_WIN32_IE_IE60SP1 (0x0601)
Internet Explorer 6.0_WIN32_IE_IE60 (0x0600)
Internet Explorer 5.5_WIN32_IE_IE55 (0x0550)
Internet Explorer 5.01_WIN32_IE_IE501 (0x0501)
Internet Explorer 5.0, 5.0a, 5.0b_WIN32_IE_IE50 (0x0500)