[Compuware Corporation] [Compuware NuMega home page]                [NuMega Lab]
[teal]

 [DriverStudio]    [Image][Image]
   Home
 [Driver Products]        Driver Technical Tips
   DriverStudio          Distinguishing Windows 98 from NT in WDM Drivers
   DriverBundle
   Previews              WDM drivers run unchanged on both Windows NT 5.0 and on Windows 98. This is one
   Compatibility         of the key benefits of WDM, but there may be cases where a driver needs to
 [Downloads]             behave differently on the two platforms. Since there is no documented service at
                          kernel level that reports the identity of the platform, this could present a
 Wizards                  problem for driver developers.
   Utilities
   NT source             The system registry provides a solution. We suggest checking for the presence of
 examples                 key \Registry\Machine\SAM. If the key is present, it is safe to assume that the
   VxD source            system is Windows NT. The key relates to the Security Accounts Manager, and so
 examples                 should never be present on a Windows 98 system. One might naively think that key
   WDM source            \Registry\Machine\Software\Microsoft\Windows NT would provide a good test for an
 examples                 NT system, but in fact this key appears on many Windows 98 systems.
 [Resources]  
 Technical papers         Here's the code to check for the existence of \Registry\Machine\SAM if you are
   Useful links          using the DDK:
   Technical tips
 [Support]               BOOLEAN RunningOnNT(void)
                          {
 Support                          OBJECT_ATTRIBUTES oa;
   Knowledge base                UNICODE_STRING sam;
   Problem                       HANDLE hKey;
 submission                       NTSTATUS status;
   Product
 registration                     RtlInitUnicodeString(&sam, L"\\Registry\\Machine\\SAM");
   Release notes
 [Shop NuMega]                   InitializeObjectAttributes(&oa, &sam, OBJ_CASE_INSENSITIVE, NULL, NULL);
 Buy it!
   Price list                    status = ZwOpenKey(&hKey, 0, &oa);
   How to buy
   Sales offices                 if ( NT_SUCCESS(status) )
                                  {
                                          ZwClose(hKey);
 [Y2K Compliance]                         return TRUE;
                                  }
                                  else
 [More information]                       return FALSE;
                          }

                          In DriverWorks version 2.0, a driver can simply check the global BOOLEAN
                          _bWindows98_, which is TRUE when running on a Windows 98 system.

                          Back to technical tip start page.

  DriverCentral  DriverStudio  Free downloads  Resources  Support and
                          Services  Shop NuMega
     Compuware NuMega  Tel: +1 603 578-8400  Updated: 9 August 1999 
                      Problems? Contact our webmaster.
