| Home | Table of Contents | Please view with Internet Explorer (version 5.00 or higher) and enable scripting. For reasons, see Browsing This Web Site. |
CURRENT WORK ITEM - PREVIEW ONLY
BOOL IsOS (DWORD dwOS);
The dwOS argument selects a question about the operating system, or at least about the current process’s relationship with the operating system. Rather than attempt a description of which versions, editions and other variations of Microsoft’s operating systems satisfy which questions, the following table summarises the recent implementations as generally as seems practicable. The descriptions in terms of platform, version, build, product type and suite are common to many cases, as are the descriptions in terms of system metrics, and are explained in the section on Behaviour. Such description is complete for most cases. Other cases are elaborated on separate pages.
| Constant | Symbolic Name | Test |
|---|---|---|
| 0x00 | OS_WINDOWS | platform is Windows |
| 0x01 | OS_NT | platform is NT |
| 0x02 | OS_WIN95ORGREATER | platform is Windows and major version >= 4 |
| 0x03 | OS_NT4ORGREATER | platform is NT and major version >= 4 |
| 0x04 | undocumented | platform is NT and major version >= 5 |
| 0x05 | OS_WIN98ORGREATER | platform is Windows and version >= 4.10 |
| 0x06 | OS_WIN98_GOLD | platform is Windows and version is 4.10 and build is 1998 |
| 0x07 | OS_WIN2000ORGREATER | platform is NT and major version >= 5 (but see below for variations) |
| 0x08 | OS_WIN2000PRO | product type is workstation and major version is 5 |
| 0x09 | OS_WIN2000SERVER | product type is domain controller or server; and suite is neither enterprise nor data center; and major version is 5 |
| 0x0A | OS_WIN2000ADVSERVER | product type is domain controller or server; and major version is 5; and suite is enterprise but not data center |
| 0x0B | OS_WIN2000DATACENTER | product type is domain controller or server; and major version is 5; and suite is data center |
| 0x0C | OS_WIN2000TERMINAL | suite is terminal and major version >= 5 |
| 0x0D | OS_EMBEDDED | suite is embedded |
| 0x0E | OS_TERMINALCLIENT | evaluation of system metric SM_REMOTESESSION |
| 0x0F | OS_TERMINALREMOTEADMIN | suite is terminal and single user |
| 0x10 | OS_WIN95_GOLD | platform is Windows and version is 4.00 and build is 950 (but see below for variations) |
| 0x11 | OS_MEORGREATER | platform is Windows and version >= 4.90 |
| 0x12 | OS_XPORGREATER | platform is NT and version > 5.00 (but see below for variations) |
| 0x13 | OS_HOME | platform is NT and suite is personal |
| 0x14 | OS_PROFESSIONAL | platform is NT and product type is workstation |
| 0x15 | OS_DATACENTER | product type is domain controller or server; and suite is data center |
| 0x16 | OS_ADVSERVER | product type is domain controller or server; and suite is enterprise but not data center |
| 0x17 | OS_SERVER | product type is domain controller or server; and suite is neither enterprise nor data center; (but see below for variations) |
| 0x18 | OS_TERMINALSERVER | suite is terminal and not single user |
| 0x19 | OS_PERSONALTERMINALSERVER | suite is single user and not terminal |
| 0x1A | OS_FASTUSERSWITCHING | suite is terminal or single user; and multiple Terminal Services sessions are allowed |
| 0x1B | OS_WELCOMELOGONUI | implementation-dependent constraints; and logon by Welcome screen is enabled |
| 0x1C | OS_DOMAINMEMBER | is joined to domain |
| 0x1D | OS_ANYSERVER | product type is domain controller or server |
| 0x1E | OS_WOW6432 | current process is 32-bit on WOW64 |
| 0x1F | OS_WEBSERVER | suite is blade |
| 0x20 | OS_SMALLBUSINESSSERVER | suite is small business restricted |
| 0x21 | OS_TABLETPC | supports table hardware |
| 0x22 | OS_SERVERADMINUI | evaluation of ServerAdminUI from registry |
| 0x23 | OS_MEDIACENTER | evaluation of system metric SM_MEDIACENTER |
| 0x24 | OS_APPLIANCE | Appliance Server is installed |
| 0x25 | undocumented | platform is NT and major version >= 6 |
| 0x26 | undocumented | evaluation of system metric SM_STARTER |
| 0x27 | undocumented | product type is domain controller |
| 0x28 | undocumented | Windows is 64-bit, if SHLWAPI from Windows Vista; suite is storage server, if SHLWAPI from Windows Server 2003 SP1 |
| 0x29 | undocumented | suite is compute server |
| 0x2A | undocumented | system metric SM_SERVERR2 is non-zero |
| 0x2B | undocumented | evaluation of undocumented system metric 0x2003 |
| 0x2C | undocumented | evaluation of undocumented system metric 0x2004 |
The function returns a non-zero value to indicate that the tested condition is satisfied, else the function returns FALSE. The non-zero value is not necessarily TRUE.
The function depends heavily, as might anyone, on the version information reported by the standard API function GetVersionEx. This information is sought only the first time that the IsOS function is called (per-process). The IsOS function asks first to have an OSVERSIONINFOEXA structure filled, and failing that, an OSVERSIONINFOA structure. Having got (or already having) this version information, the function sets about interpreting it for the question implied by the dwOS argument. The function returns FALSE if dwOS is not one of the supported constants.
To save space in the preceding table, and throughout this article, some shorthands are used for the members of the version information structure and the values they can take. None should be unclear, but they are all listed below for definiteness:
The wSuiteMask member lies in the extension from OSVERSIONINFO to OSVERSIONINFOEX, and even though the extended structure is sought by all exported implementations of IsOS, i.e., in version 5.00 and higher, this member is not interpreted until late 5.00 builds. Earlier builds work instead with a registry value:
| Key | HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ProductOptions |
| Value | ProductType |
| Type | REG_SZ |
The string data Enterprise and DataCenter are then treated as equivalent to “suite is enterprise” and “suite is data center” respectively. As with the version information, the function seeks this registry value only when first called (per-process).
In a few cases that depend solely on the (system) version information, the interpretation varies slightly with the SHLWAPI version.
| Case | SHLWAPI Versions | Test |
|---|---|---|
| OS_WIN2000ORGREATER | initially | product type is workstation, domain controller or server; and major version >= 5 |
| 6.00 and higher | platform is NT and major version >= 5 | |
| OS_WIN95_GOLD | initially | platform is Windows and version is 4.00 and build is 1995 |
| 6.00 and higher | platform is Windows and version is 4.00 and build is 950 | |
| OS_XPORGREATER | initially | platform is NT and version >= 5.00, but version == 5.00 only if build > 2195 |
| Windows Vista | platform is NT and version > 5.00 | |
| OS_SERVER | initially | product type is domain controller or server; and suite is neither enterprise nor data center |
| Windows XP SP2; Windows Server 2003 SP1 |
product type is domain controller or server; and suite is none of enterprise, data center, small business restricted or blade |
|
| Windows Server 2003; Windows Vista |
product type is domain controller or server; and suite is none of small business, enterprise, data center, small business restricted or blade |
Note that the change in OS_WIN2000ORGREATER (0x07) for version 6.00 makes it an alias for the undocumented case 0x04. The latter is in fact the original, dating from versions 4.71 and 4.72 when IsOS was coded in both SHLWAPI and SHDOCVW but not exported from either. The documented case 0x07 does have the merit of a better fit with the chronology of releases: case 0x04 was being used, e.g., by SHDOCVW in Internet Explorer 4.0, to distinguish “Windows 2000 or greater” some two years before Windows 2000 was released.
The change in OS_WIN95_GOLD is presumably a bug fix, the earlier coding having picked an incorrect build number.
In the following cases, which all involve testing the wSuiteMask member for a single flag, the function does not return TRUE if the flag is set, but instead returns the flag:
A handful of cases are answered by calling the standard API function GetSystemMetrics to obtain a particular system metric. Where such cases are described in the preceding table as “evaluation of system metric”, it is to be understood that the IsOS function returns the metric exactly as returned by GetSystemMetrics, as opposed to returning TRUE or FALSE depending on whether the metric is non-zero or zero.
The IsOS function is exported from SHLWAPI as ordinal 437 in version 5.00 and higher. Starting with Windows Vista, the function is also exported by name.
The matter of which cases of dwOS are supported in which versions is extremely untidy—even without the variations in what is tested for each case. For the following table, a case is deemed supported if it is not coded to return FALSE trivially.
| Cases | Versions |
|---|---|
| 0x00 to 0x0C | version 5.00 and higher |
| 0x0D to 0x10 | late 5.00 builds and higher |
| 0x11 | version 5.50 and higher |
| 0x12 to 0x14 | version 6.00 and higher |
| 0x15 | Internet Explorer 5.01 (but only for Windows 2000 and higher); Windows 2000 from SP1; late 5.50 builds and higher |
| 0x16 to 0x1E | version 6.00 and higher |
| 0x1F and 0x20 | late 6.00 builds and higher |
| 0x21 | post-settlement 6.00 builds and higher |
| 0x22 | late 6.00 builds and higher |
| 0x23 | post-settlement 6.00 builds and higher |
| 0x24 | late 6.00 builds and higher |
| 0x25 | Windows Vista |
| 0x26 | very late 6.00 builds and higher |
| 0x27 | Windows Vista |
| 0x28 | Windows Server 2003 SP1; Windows Vista |
| 0x29 and 0x2A | Windows Server 2003 SP1 |
| 0x2B and 0x2C | Windows XP SP2 |
Though this function dates from as long ago as 1999, it was still not documented by Microsoft in the MSDN Library at least as late as the CD edition dated January 2004.
However, the function did eventually get documented, apparently later in 2004. This article now conforms to Microsoft’s nomenclature.
Note that Microsoft is hardly rushing to keep its new documentation up to date. The several new cases of dwOS that are supported in Windows XP SP2, Windows Server 2003 SP1 and Windows Vista were not yet documented by Microsoft in the Windows Vista SDK dated January 2007.