Link to home
Start Free TrialLog in
Avatar of Greedy
Greedy

asked on

Getting the OS

I need to be able to find the OS that I am executing a 16 bit DOS app in... can be any of these
1) DOS - get the ver
2) Win 3.11
3) Win 95
4) Win 98
5) Win NT (Get Build/Ver) and maby even SP
6) OS/2 Get Ver

Thanks....I'm useing Pacific C to do this...but I have other C complers...I've just forgot how to do this it's been like 6 years since I wrote anything for DOS well anything that I had to know if it was 16 or 32 bit....oh well Thanks
Avatar of AlexVirochovsky
AlexVirochovsky

You can use next algoritm:
  FILE *fIn;
  system ("ver >ver.txt"); //make file ver.txt with Version
  sleep(1);//wait end of ver
  fIn = fopen (ver.txt, "rt");
  ....//you code for define Version and make something
  fclose(fIn);
In my example I get (as 2-nd line)
Windows 95. [Version 4.00.950]
Good Luck, Alex

Avatar of Greedy

ASKER

Well, yeah I thought of that but since it sucks I decided not to do that...I want to directly ask the command processor what it is...what if the user can't write to any device?

Suggestion #1:

INT 21 - DOS 2+ - GET DOS VERSION
      AH = 30h
---DOS 5+ ---
      AL = what to return in BH
          00h OEM number (as for DOS 2.0-4.0x)
          01h version flag
Return: AL = major version number (00h if DOS 1.x)
      AH = minor version number
      BL:CX = 24-bit user serial number (most versions do not use this)
---if DOS <5 or AL=00h---
      BH = MS-DOS OEM number (see #01394)
---if DOS 5+ and AL=01h---
      BH = version flag
          bit 3: DOS is in ROM
          other: reserved (0)

Notes:
the OS/2 v1.x Compatibility Box returns major version 0Ah (10)
the OS/2 v2.x Compatibility Box returns major version 14h (20)
OS/2 Warp 3.0 Virtual DOS Machines report v20.30; Warp 4 VDMs report
  v20.40.
the WindowsNT DOS box returns version 5.00, subject to SETVER
DOS 4.01 and 4.02 identify themselves as version 4.00; use
  INT 21/AH=87h to distinguish between the original European MS-DOS 4.0
  and the later PC-DOS 4.0x and MS-DOS 4.0x
IBM DOS 6.1 reports its version as 6.00; use the OEM number to
  distinguish between MS-DOS 6.00 and IBM DOS 6.1 (there was never an
  IBM DOS 6.0)
MS-DOS 6.21 reports its version as 6.20; version 6.22 returns the
  correct value
Windows95 returns version 7.00 (the underlying MS-DOS), as did the
  "Chicago" beta (reported in _Microsoft_Systems_Journal_,August 1994);
  Windows95 OSR2 returns version 7.10
DR DOS 5.0 and 6.0 report version 3.31; Novell DOS 7 reports IBM v6.00,
  which some software displays as IBM DOS v6.10 (because of the version
  mismatch in true IBM DOS, as mentioned above).  The Novell DOS 7
  SETVER.EXE has an undocumented option /G x.y which sets the "global"
  DOS version returned by this function for all executables not given
  a specific version number in SETVER to major version x and minor
  version y.
generic MS-DOS 3.30, Compaq MS-DOS 3.31, and others identify themselves
  as PC-DOS by returning OEM number 00h
the version returned under DOS 4.0x may be modified by entries in
  the special program list (see #01662 at AH=52h); the version returned
  under DOS 5+ may be modified by SETVER--use AX=3306h to get the true
  version number
SeeAlso: AX=3000h/BX=3000h,AX=3306h,AX=4452h,AH=87h,INT 15/AX=4900h
SeeAlso: INT 2F/AX=122Fh,INT 2F/AX=4010h,INT 2F/AX=4A33h,INT 2F/AX=E002h

(Table 01394)
Values for DOS OEM number:
 00h      IBM
 01h      Compaq
 02h      MS Packaged Product
 04h      AT&T
 05h      ZDS (Zenith Electronics)
 06h      Hewlett-Packard
 07h      ZDS (Groupe Bull)
 0Dh      Packard-Bell
 16h      DEC
 23h      Olivetti
 28h      Texas Instruments
 29h      Toshiba
 33h      Novell (Windows/386 device IDs only)
 34h      MS Multimedia Systems (Windows/386 device IDs only)
 35h      MS Multimedia Systems (Windows/386 device IDs only)
 4Dh      Hewlett-Packard
 5Eh      RxDOS
 66h      PhysTechSoft (PTS-DOS)
 99h      General Software's Embedded DOS
 EEh      DR DOS
 EFh      Novell DOS
 FDh      FreeDOS
 FFh      Microsoft, Phoenix

Suggestion #2:

INT 21 - DOS 5+ - GET TRUE VERSION NUMBER
      AX = 3306h
Return: BL = major version
      BH = minor version
      DL = revision (bits 2-0, all others 0)
      DH = version flags
          bit 3: DOS is in ROM
          bit 4: DOS is in HMA
      AL = FFh if true DOS version < 5.0

Notes:
this function always returns the true version number, unlike AH=30h,
  whose return value may be changed with SETVER
because of the conflict from the CBIS redirector (see next
  entry), programs should check whether BH is less than 100 (64h)
  and BL is at least 5 before accepting the returned BX as the true
  version number; however, even this is not entirely reliable when
  that redirector is loaded
fully reentrant
OS/2 v2.1 will return BX=0A14h (version 20.10)
the Windows NT DOS box returns BX=3205h (version 5.50)
Novell DOS 7 returns IBM v6.00, which some software displays as
  IBM DOS v6.10 (because of the version mismatch in true IBM DOS
  mentioned for INT 21/AH=30h); versions through Update 15 all
  return revision code 00h
Windows95 and Windows95 SP1 return version 7.00; Windows95 OSR2 returns
  version 7.10

BUG:
DR DOS 5.0 and 6.0 return CF set/AX=0001h for INT 21/AH=33h
  subfunctions other than 00h-02h and 05h, while MS-DOS returns AL=FFh
  for invalid subfunctions

Suggestion #3 (os specific):

INT 2F - MS Windows 3.1 - IDENTIFY WINDOWS VERSION AND TYPE
      AX = 160Ah
Return: AX = 0000h if call supported
          BX = version (BH=major, BL=minor)
          CX = mode (0002h = standard, 0003h = enhanced)

INT 2F - OS/2 v2.0+ - INSTALLATION CHECK / GET VERSION
      AX = 4010h
Return: AX = 4010h if OS/2 not installed
      AX = 0000h for OS/2 Warp 3.0
      BX = OS/2 version if installed
Note:      OS/2 Warp 3.0

ASKER CERTIFIED SOLUTION
Avatar of alexo
alexo
Flag of Antarctica image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
to AlexO: you reply is exellent, but not very easy!
I thihk, that function "ver" exactly make something like
this and we can get same functionality more simple (using
"ver").

AV, since Greedy labeled the "ver" solution with the word "sucks" I assume he didn't like it.  As to why, I can only speculate...

One question though, why would you need the sleep()?  system() is synchronous.
Really, i think sleep is useless hier.
Avatar of Greedy

ASKER

Cool I can do that...I was wondering if anyone has the Windows 3.1 SDK it apparently has a GetVersion() prototype for this in the windows.h

support article ID Q80783

http://support.microsoft.com/support/kb/articles/Q80/7/83.asp