How to detect win9 vs NT?

Geoffrey Noer
Tue Aug 18 04:14:00 GMT 1998

On Sun, Aug 16, 1998 at 11:22:53AM -0400, wrote:
> Are we going to assume that things should run correctly only on the
> type of system they were built on?  I suppose there are things which
> might be fixed to facilitate builds, but I thought that cpu_time()
> and clock() should check at run time the first time they are called
> to see which system is running.

Yes, runtime is the way to go for this sort of thing.  The
development version of Cygwin32 checks the type of OS running when the
DLL loads.  It stores the result in a global variable that is
consulted whenever a runtime choice needs to be made.  Appended is the
code that does this (from winsup/ in the development

Geoffrey Noer

-------------------------- snip ------------------------------

enum os_type {winNT, win95, win98, win32s, unknown};

/* remember the type of Win32 OS being run for future use. */
os_type NO_COPY os_being_run;

/* set_os_type: Set global variable os_being_run with type of Win32
   operating system being run.  This information is used internally
   to manage the inconsistency in Win32 API calls between Win32
   OSes. */
/* Cygwin32 internal */
set_os_type ()
  OSVERSIONINFO os_version_info;
  os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);

  GetVersionEx (&os_version_info);

  switch (os_version_info.dwPlatformId)
      case VER_PLATFORM_WIN32_NT:
        os_being_run = winNT;
        if (os_version_info.dwMinorVersion == 0)
          os_being_run = win95;
        else /* os_version_info.dwMinorVersion == 10 */
          os_being_run = win98;
      case VER_PLATFORM_WIN32s:
        os_being_run = win32s;
        os_being_run = unknown;
For help on using this list (especially unsubscribing), send a message to
"" with one line of text: "help".

More information about the Cygwin mailing list