Mail Archives: djgpp/1997/08/18/04:40:11
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, ®s);
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 -