delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/18/04:40:11

Message-Id: <3.0.1.16.19970818090815.21c702ee@mailhost.sm.ic.ac.uk>
Date: Mon, 18 Aug 1997 09:08:15
To: djgpp AT delorie DOT com
From: Paul Dixon <p DOT dixon AT ic DOT ac DOT uk>
Subject: Re: Detecting NT
Mime-Version: 1.0

The following code is tested and works as expected on all of vanilla DOS,
Win3x, Win95, WinNT351, WinNT4 (ie _get_win_version returns non-zero for
Win3x and Win95, _detect_NT returns 0 for all others, non-zero for both NT
flavours). The call to _get_win_version() in _detect_NT is actually
superfluous but is in the code as used and tested (the project that it was
snipped from tests absolutely _everything_ it can in case it needs to
crash-dump!)

I have NOT yet identified a way of distinguishing between the two versions
of NT - any ideas?

Paul
------------------------------------------------------------------------------
#include <dpmi.h>
#include <dos.h>

/* Return windows version number, or 0 if not returned */

unsigned short _get_win_version()
{
  __dpmi_regs       regs;

  regs.x.ax = 0x160a;
  __dpmi_int(0x2f, &regs);
  if (regs.x.ax) return 0;
  else return regs.x.bx;
}

/* Recognise NT - works for both NT3.51 and NT4.0 */
int _detect_NT()
{
  return (_get_win_version() == 0 && _get_dos_version(1) == 0x532);
}

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019