Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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.
#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");
}
}
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today