Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting the OS

Posted on 1999-07-26
10
Medium Priority
?
214 Views
Last Modified: 2010-04-15
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
0
Comment
Question by:Greedy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1263951
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

0
 
LVL 1

Author Comment

by:Greedy
ID: 1263952
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?

0
 
LVL 11

Expert Comment

by:alexo
ID: 1263953
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

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 11

Expert Comment

by:alexo
ID: 1263954
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

0
 
LVL 11

Expert Comment

by:alexo
ID: 1263955
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

0
 
LVL 11

Accepted Solution

by:
alexo earned 400 total points
ID: 1263956
[See my previous comments]

I don't know what is the available method of calling a software interrupt that your compiler supports but try one of the following (from Borland's manual):
    int86()
    int86x()
    intdos()
    intdosx()
    intr()

Or, you can invoke assembly code from C by using the asm (or _asm or __asm) directive.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1263957
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").

0
 
LVL 11

Expert Comment

by:alexo
ID: 1263958
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.
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 1263959
Really, i think sleep is useless hier.
0
 
LVL 1

Author Comment

by:Greedy
ID: 1263960
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
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question