Geoff Chappell - Software Analyst
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. Not all questions are supported in all SHLWAPI versions. Not all values of dwOS select the same question in all SHLWAPI versions.
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. In versions before 6.1, this information is sought only the first time that the IsOS function is called. The IsOS function asks first to have an OSVERSIONINFOEXA structure filled, and failing that, an OSVERSIONINFOA structure. Success at getting one or the other is assumed. Having got (or already having) this version information, the function sets about interpreting it for the question implied by the dwOS argument. In version 6.1 and higher, the function asks for version information only when needed for the particular question, and only then as an OSVERSIONINFOEXW structure, and the function fails (returns FALSE) if this version information is not available.
The function fails if dwOS is not one of the supported constants.
Rather than attempt a description of which versions, editions and other variations of Microsoft’s operating systems satisfy which questions, the following table summarises what the function tests to answer the question. The descriptions in terms of platform, version, build, product type and suite, as obtained from GetVersionEx, are common to many cases, as are the descriptions in terms of system metrics, and are explained in the section on Behaviour. Such descriptions are complete for most values of dwOS. Other cases are elaborated on separate pages. The table is regrettably wide, mostly to account for variations in what is tested by which SHLWAPI versions.
Constant | Symbolic Name | SHLWAPI Version | Summary of Test |
---|---|---|---|
0x00 | OS_WINDOWS | 5.0 and higher | platform is Windows |
0x01 | OS_NT | 5.0 and higher | platform is NT |
0x02 | OS_WIN95ORGREATER | 5.0 and higher | platform is Windows and major version ≥ 4 |
0x03 | OS_NT4ORGREATER | 5.0 and higher | platform is NT and major version ≥ 4 |
0x04 | 5.0 and higher | platform is NT and major version ≥ 5 | |
0x05 | OS_WIN98ORGREATER | 5.0 and higher | platform is Windows and version ≥ 4.10 |
0x06 | OS_WIN98_GOLD | 5.0 and higher | platform is Windows and version is 4.10 and build is 1998 |
0x07 | OS_WIN2000ORGREATER | 5.0 and 5.50 | product type is workstation, domain controller or server; and major version ≥ 5 |
6.0 and higher | platform is NT and major version ≥ 5 | ||
0x08 | OS_WIN2000PRO | 5.0 and higher | product type is workstation and major version is 5 |
0x09 | OS_WIN2000SERVER | 5.0 and higher | product type is domain controller or server; and suite is neither enterprise nor data center; and major version is 5 |
0x0A | OS_WIN2000ADVSERVER | 5.0 and higher | product type is domain controller or server; and major version is 5; and suite is enterprise but not data center |
0x0B | OS_WIN2000DATACENTER | 5.0 and higher | product type is domain controller or server; and major version is 5; and suite is data center |
0x0C | OS_WIN2000TERMINAL | 5.0 before Windows 2000 | evaluation of system metric SM_REMOTESESSION |
5.0 from Windows 2000, and higher | suite is terminal and major version ≥ 5 | ||
0x0D | OS_EMBEDDED | 5.0 from Windows 2000, and higher | suite is embedded |
0x0E | OS_TERMINALCLIENT | 5.0 from Windows 2000 and higher, and 5.50 and 6.0 | evaluation of system metric SM_REMOTESESSION |
6.1 and higher | system metric SM_REMOTESESSION is non-zero | ||
0x0F | OS_TERMINALREMOTEADMIN | 5.0 from Windows 2000 and higher, and 5.50 | suite is terminal and major version ≥ 5; and TSAppCompat registry value is zero |
6.0 and higher | suite is terminal and single user | ||
0x10 | OS_WIN95_GOLD | 5.0 from Windows 2000 and higher, and 5.50 | platform is Windows and version is 4.0 and build is 1995 |
6.0 and higher | platform is Windows and version is 4.0 and build is 950 | ||
0x11 | OS_MEORGREATER | 5.50 and higher | platform is Windows and version ≥ 4.90 |
0x12 | OS_XPORGREATER | 6.0 before Windows Vista | platform is NT and version ≥ 5.0, but version is 5.0 only if build > 2195 |
6.0 from Windows Vista, and higher | platform is NT and version > 5.0 | ||
0x13 | OS_HOME (also known as OS_PERSONAL) |
6.0 and higher | platform is NT and suite is personal |
0x14 | OS_PROFESSIONAL | 6.0 and higher | platform is NT and product type is workstation |
0x15 | OS_DATACENTER | 5.0 from Internet Explorer 5.01 (for Windows 2000); 5.0 from Windows 2000 SP1 and higher; 5.50 from Internet Explorer 5.5 SP2 |
product type is server; and major version is 5; and suite is both enterprise and blade, but not data center |
6.0 and higher | product type is domain controller or server; and suite is data center |
||
0x16 | OS_ADVSERVER | 6.0 and higher | product type is domain controller or server; and suite is enterprise but not data center |
0x17 | OS_SERVER | 6.0 before Windows XP SP2 | product type is domain controller or server; and suite is neither enterprise nor data center |
6.0 from Windows XP SP2 and SP3; 6.0 from Windows Server 2003 SP1 and SP2 |
product type is domain controller or server; and suite is none of enterprise, small business restricted, data center or blade |
||
6.0 from original Windows Server 2003; 6.0 from Windows Vista, and higher |
product type is domain controller or server; and suite is none of small business, enterprise, small business restricted, data center or blade |
||
0x18 | OS_TERMINALSERVER | 6.0 and higher | suite is terminal and not single user |
0x19 | OS_PERSONALTERMINALSERVER | 6.0 and higher | suite is single user and not terminal |
0x1A | OS_FASTUSERSWITCHING | 6.0 and higher | suite is terminal or single user; and multiple Terminal Services sessions are allowed |
0x1B | OS_WELCOMELOGONUI | 6.0 | logon by Welcome screen is enabled |
0x1C | OS_DOMAINMEMBER | 6.0 and higher | is joined to domain |
0x1D | OS_ANYSERVER | 6.0 and higher | product type is domain controller or server |
0x1E | OS_WOW6432 | 6.0 and higher | current process is 32-bit on WOW64 |
0x1F | OS_WEBSERVER (also known as OS_BLADE) |
6.0 from Windows XP SP2, and higher | suite is blade |
0x20 | OS_SMALLBUSINESSSERVER | 6.0 from Windows XP SP2, and higher | suite is small business restricted |
0x21 | OS_TABLETPC | 6.0 from Windows XP SP1, before Windows Vista | evaluation of system metric SM_TABLETPC |
6.0 from Windows Vista, and higher | supports tablet hardware | ||
0x22 | OS_SERVERADMINUI | 6.0 from Windows XP SP2, and higher | evaluation of ServerAdminUI from registry |
0x23 | OS_MEDIACENTER | 6.0 from Windows XP SP1, and higher | evaluation of system metric SM_MEDIACENTER |
0x24 | OS_APPLIANCE | 6.0 from Windows XP SP2, and higher | Appliance Server is installed |
0x25 | OS_VISTAORGREATER | 6.0 from Windows Vista, and higher | platform is NT and major version ≥ 6 |
0x26 | 6.0 from Windows XP SP2 and Windows Server 2003 SP1, and higher | evaluation of system metric SM_STARTER | |
0x27 | OS_DOMAINCONTROLLER | 6.0 from Windows Vista, and higher | product type is domain controller |
0x28 | perhaps OS_WIN64 | 6.0 from Windows Server 2003 SP1 and SP2 | suite is storage server |
6.0 from Windows Vista, and higher | is running on 64-bit Windows | ||
0x29 | OS_WIN7ORGREATER | 6.0 from Windows Server 2003 SP1 and SP2 only | suite is compute server |
6.1 and higher | platform is NT and version > 6.0 | ||
0x2A | 6.0 from Windows Server 2003 SP1 and SP2 only | system metric SM_SERVERR2 is non-zero | |
0x2B | 6.0 from Windows XP SP2 and SP3 only | evaluation of undocumented system metric 0x2003 | |
6.0 from Windows Server 2003 SP2 only | suite is home server | ||
0x2C | 6.0 from Windows XP SP2 and SP3 only | evaluation of undocumented system metric 0x2004 |
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, this member is not interpreted until the builds of version 5.0 from Windows 2000. 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 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:
The change in OS_WIN2000ORGREATER (0x07) for version 6.0 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.
Note that the early test for OS_WIN2000TERMINAL was not discarded: it got reused as OS_TERMINALCLIENT.
For some values of dwOS, version 6.1 returns a hard-coded result that is consistent with the question as understood by previous versions:
Case | Hard Coded Evaluation |
---|---|
OS_NT OS_NT4ORGREATER OS_XPORGREATER |
TRUE in 6.1 and higher |
OS_WIN95ORGREATER OS_WIN98ORGREATER OS_WIN98GOLD OS_WIN95_GOLD OS_MEORGREATER |
FALSE in 6.1 and higher |
It is not known why the function takes for granted that it is running on Windows XP or greater but still tests whether it is running on Windows 2000 or greater.
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”, the function returns exactly whatever is returned by GetSystemMetrics, without regard for whether this is TRUE or FALSE.
The IsOS function is exported from SHLWAPI as ordinal 437 in version 5.0 and higher. Starting with version 6.0 from Windows Vista, the function is also exported by name.
It exists earlier, in both SHLWAPI and SHDOCVW from Internet Explorer 4.0 in 1997, but only as an internal routine.
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. Some names for these undocumented cases are inferred from the names of subroutines in version 6.1.
A substantial revision of the SDK documentation, apparently done some time during 2008 or 2009, seems intended to describe the function as it behaves in SHLWAPI version 6.1, but notes that “Values are not provided for Windows Vista and Windows 7.” An alternative is suggested. This is just as well. As shown above, some of the “values” introduced since Windows XP SP2 are interpreted very differently depending on which SHLWAPI version is asked. This is no problem for Microsoft’s own use of IsOS in Internet Explorer, since SHLWAPI is linked statically into the IEFRAME executable and Microsoft therefore has complete control of which version of the SHLWAPI code is called. The situation is different for programs that import from SHLWAPI. These may find themselves calling any of a wide variety of SHLWAPI versions. They are therefore exposed to such problems as getting a false positive from OS_WIN7ORGREATER if they happen to be running on certain editions of certain builds of Windows Server 2003. For such reasons, many of these new dwOS values really would be much better left alone. Whether this is why Microsoft does not update its documentation to cover these new values is, of course, not known.