Microsoft- Operating System Version
The Version API Helper functions are used to determine the version of the operating system that is currently running. For more information, see Getting the System Version.
The following table summarizes the most recent operating system version numbers.
Operating system | Version number |
---|---|
Windows 10 | 10.0* |
Windows Server 2016 | 10.0* |
Windows 8.1 | 6.3* |
Windows Server 2012 R2 | 6.3* |
Windows 8 | 6.2 |
Windows Server 2012 | 6.2 |
Windows 7 | 6.1 |
Windows Server 2008 R2 | 6.1 |
Windows Server 2008 | 6.0 |
Windows Vista | 6.0 |
Windows Server 2003 R2 | 5.2 |
Windows Server 2003 | 5.2 |
Windows XP 64-Bit Edition | 5.2 |
Windows XP | 5.1 |
Windows 2000 | 5.0 |
* For applications that have been manifested for Windows 8.1 or Windows 10. Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). To manifest your applications for Windows 8.1 or Windows 10.
|
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using the Version API Helper functions to determine the operating system platform or version number, test for the presence of the feature itself.
To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection:
- You can test for the presence of the functions associated with a feature. To test for the presence of a function in a system DLL, call theLoadLibrary function to load the DLL. Then call the GetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to call the function. Note that even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTED.
- You can determine the presence of some features by using the GetSystemMetrics function. For example, you can detect multiple display monitors by calling GetSystemMetrics(SM_CMONITORS).
- There are several versions of the redistributable DLLs that implement shell and common control features. For information about determining which versions are present on the system your application is running on, see the topic Shell and Common Controls Versions.
If you must require a particular operating system, be sure to use it as a minimum supported version, rather than design the test for the one operating system. This way, your detection code will continue to work on future versions of Windows.
Note that a 32-bit application can detect whether it is running under WOW64 by calling the IsWow64Process function. It can obtain additional processor information by calling the GetNativeSystemInfo function.
Getting the System Version
The following example uses the Version API Helper functions to determine the version of the current operating system, if it is a Server or Client release, and then displays this information to the console. If compatibility mode is in effect, the example displays the operating system selected for application compatibility.
To obtain the full version number for the operating system, call the GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll, then call VerQueryValue to obtain the \\StringFileInfo\\<lang><codepage>\\ProductVersion subblock of the file version information.
Relying on version information is not the best way to test for a feature. Instead, refer to the documentation for the feature of interest. For more information on common techniques for feature detection, see Operating System Version.
C++
#include <windows.h> #include <stdio.h> #include <VersionHelpers.h> int __cdecl wmain( __in int argc, __in_ecount(argc) PCWSTR argv[] ) { UNREFERENCED_PARAMETER(argc); UNREFERENCED_PARAMETER(argv); if (IsWindowsXPOrGreater()) { printf("XPOrGreater\n"); } if (IsWindowsXPSP1OrGreater()) { printf("XPSP1OrGreater\n"); } if (IsWindowsXPSP2OrGreater()) { printf("XPSP2OrGreater\n"); } if (IsWindowsXPSP3OrGreater()) { printf("XPSP3OrGreater\n"); } if (IsWindowsVistaOrGreater()) { printf("VistaOrGreater\n"); } if (IsWindowsVistaSP1OrGreater()) { printf("VistaSP1OrGreater\n"); } if (IsWindowsVistaSP2OrGreater()) { printf("VistaSP2OrGreater\n"); } if (IsWindows7OrGreater()) { printf("Windows7OrGreater\n"); } if (IsWindows7SP1OrGreater()) { printf("Windows7SP1OrGreater\n"); } if (IsWindows8OrGreater()) { printf("Windows8OrGreater\n"); } if (IsWindows8Point1OrGreater()) { printf("Windows8Point1OrGreater\n"); } if (IsWindows10OrGreater()) { printf("Windows10OrGreater\n"); } if (IsWindowsServer()) { printf("Server\n"); } else { printf("Client\n"); } }
GetFileVersionInfo function
Retrieves version information for the specified file.
Syntax
C++
BOOL WINAPI GetFileVersionInfo( _In_ LPCTSTR lptstrFilename, _Reserved_ DWORD dwHandle, _In_ DWORD dwLen, _Out_ LPVOID lpData );
Parameters
- lptstrFilename [in]
- Type: LPCTSTRThe name of the file. If a full path is not specified, the function uses the search sequence specified by the LoadLibrary function.
- dwHandle
- Type: DWORDThis parameter is ignored.
- dwLen [in]
- Type: DWORDThe size, in bytes, of the buffer pointed to by the lpData parameter.Call the GetFileVersionInfoSize function first to determine the size, in bytes, of a file's version information. The dwLen member should be equal to or greater than that value.If the buffer pointed to by lpData is not large enough, the function truncates the file's version information to the size of the buffer.
- lpData [out]
- Type: LPVOIDPointer to a buffer that receives the file-version information.You can use this value in a subsequent call to the VerQueryValue function to retrieve data from the buffer.
Return value
Type: BOOL
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
File version info has fixed and non-fixed part. The fixed part contains information like version number. The non-fixed part contains things like strings. In the past GetFileVersionInfo was taking version information from the binary (exe/dll). Currently, it is querying fixed version from language neutral file (exe/dll) and the non-fixed part from mui file, merges them and returns to the user. If the given binary does not have a mui file then behavior is as in previous version.
Call the GetFileVersionInfoSize function before calling the GetFileVersionInfo function. To retrieve information from the file-version information buffer, use the VerQueryValue function.
Requirements
Minimum supported client
|
Windows 2000 Professional [desktop apps only]
|
---|---|
Minimum supported server
|
Windows 2000 Server [desktop apps only]
|
Header
|
|
Library
|
|
DLL
|
|
Unicode and ANSI names
|
GetFileVersionInfoW (Unicode) and GetFileVersionInfoA (ANSI)
|
GetFileVersionInfoSize function
Determines whether the operating system can retrieve version information for a specified file. If version information is available, GetFileVersionInfoSize returns the size, in bytes, of that information.
Determines whether the operating system can retrieve version information for a specified file. If version information is available, GetFileVersionInfoSize returns the size, in bytes, of that information.
Syntax
DWORD WINAPI GetFileVersionInfoSize(
_In_ LPCTSTR lptstrFilename,
_Out_opt_ LPDWORD lpdwHandle
);
DWORD WINAPI GetFileVersionInfoSize( _In_ LPCTSTR lptstrFilename, _Out_opt_ LPDWORD lpdwHandle );
Parameters
- lptstrFilename [in]
-
Type: LPCTSTR
The name of the file of interest. The function uses the search sequence specified by the LoadLibrary function.
- lpdwHandle [out, optional]
-
Type: LPDWORD
A pointer to a variable that the function sets to zero.
- lptstrFilename [in]
- Type: LPCTSTRThe name of the file of interest. The function uses the search sequence specified by the LoadLibrary function.
- lpdwHandle [out, optional]
- Type: LPDWORDA pointer to a variable that the function sets to zero.
Return value
Type: DWORD
If the function succeeds, the return value is the size, in bytes, of the file's version information.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Type: DWORD
If the function succeeds, the return value is the size, in bytes, of the file's version information.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Call the GetFileVersionInfoSize function before calling the GetFileVersionInfo function. The size returned by GetFileVersionInfoSize indicates the buffer size required for the version information returned by GetFileVersionInfo.
Call the GetFileVersionInfoSize function before calling the GetFileVersionInfo function. The size returned by GetFileVersionInfoSize indicates the buffer size required for the version information returned by GetFileVersionInfo.
Requirements
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
- Winver.h (include Windows.h)
Library
- Mincore.lib
DLL
- Api-ms-win-core-version-l1-1-0.dll
Unicode and ANSI names
GetFileVersionInfoSizeW (Unicode) and GetFileVersionInfoSizeA (ANSI)
Minimum supported client
|
Windows 2000 Professional [desktop apps only]
|
---|---|
Minimum supported server
|
Windows 2000 Server [desktop apps only]
|
Header
|
|
Library
|
|
DLL
|
|
Unicode and ANSI names
|
GetFileVersionInfoSizeW (Unicode) and GetFileVersionInfoSizeA (ANSI)
|
VS_VERSIONINFO structure
Represents the organization of data in a file-version resource. It is the root structure that contains all other file-version information structures.
Represents the organization of data in a file-version resource. It is the root structure that contains all other file-version information structures.
Syntax
typedef struct {
WORD wLength;
WORD wValueLength;
WORD wType;
WCHAR szKey;
WORD Padding1;
VS_FIXEDFILEINFO Value;
WORD Padding2;
WORD Children;
} VS_VERSIONINFO;
typedef struct { WORD wLength; WORD wValueLength; WORD wType; WCHAR szKey; WORD Padding1; VS_FIXEDFILEINFO Value; WORD Padding2; WORD Children; } VS_VERSIONINFO;
Members
- wLength
-
Type: WORD
-
The length, in bytes, of the VS_VERSIONINFO structure. This length does not include any padding that aligns any subsequent version resource data on a 32-bit boundary.
- wValueLength
-
Type: WORD
-
The length, in bytes, of the Value member. This value is zero if there is no Value member associated with the current version structure.
- wType
-
Type: WORD
-
The type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data.
- szKey
-
Type: WCHAR
-
The Unicode string L"VS_VERSION_INFO".
- Padding1
-
Type: WORD
-
Contains as many zero words as necessary to align the Value member on a 32-bit boundary.
- Value
-
Type: VS_FIXEDFILEINFO
-
Arbitrary data associated with this VS_VERSIONINFO structure. The wValueLength member specifies the length of this member; ifwValueLength is zero, this member does not exist.
- Padding2
-
Type: WORD
-
As many zero words as necessary to align the Children member on a 32-bit boundary. These bytes are not included inwValueLength. This member is optional.
- Children
-
Type: WORD
-
An array of zero or one StringFileInfo structures, and zero or one VarFileInfo structures that are children of the current VS_VERSIONINFO structure.
- wLength
- Type: WORD
- The length, in bytes, of the VS_VERSIONINFO structure. This length does not include any padding that aligns any subsequent version resource data on a 32-bit boundary.
- wValueLength
- Type: WORD
- The length, in bytes, of the Value member. This value is zero if there is no Value member associated with the current version structure.
- wType
- Type: WORD
- The type of data in the version resource. This member is 1 if the version resource contains text data and 0 if the version resource contains binary data.
- szKey
- Type: WCHAR
- The Unicode string L"VS_VERSION_INFO".
- Padding1
- Type: WORD
- Contains as many zero words as necessary to align the Value member on a 32-bit boundary.
- Value
- Type: VS_FIXEDFILEINFO
- Arbitrary data associated with this VS_VERSIONINFO structure. The wValueLength member specifies the length of this member; ifwValueLength is zero, this member does not exist.
- Padding2
- Type: WORD
- As many zero words as necessary to align the Children member on a 32-bit boundary. These bytes are not included inwValueLength. This member is optional.
- Children
- Type: WORD
- An array of zero or one StringFileInfo structures, and zero or one VarFileInfo structures that are children of the current VS_VERSIONINFO structure.
Remarks
This structure is not a true C-language structure because it contains variable-length members. This structure was created solely to depict the organization of data in a version resource and does not appear in any of the header files shipped with the Windows Software Development Kit (SDK).
This structure is not a true C-language structure because it contains variable-length members. This structure was created solely to depict the organization of data in a version resource and does not appear in any of the header files shipped with the Windows Software Development Kit (SDK).
Requirements
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Minimum supported client
|
Windows 2000 Professional [desktop apps only]
|
---|---|
Minimum supported server
|
Windows 2000 Server [desktop apps only]
|
See also
- Reference
- StringFileInfo
- VerQueryValue
- VarFileInfo
- VS_FIXEDFILEINFO
- Conceptual
- Version Information
- Reference
- StringFileInfo
- VerQueryValue
- VarFileInfo
- VS_FIXEDFILEINFO
- Conceptual
- Version Information
Microsoft- Operating System Version >>>>> Download Now
ReplyDelete>>>>> Download Full
Microsoft- Operating System Version >>>>> Download LINK
>>>>> Download Now
Microsoft- Operating System Version >>>>> Download Full
>>>>> Download LINK Bl