delorie.com/djgpp/doc/libc/libc_374.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

_get_dos_version

Syntax

 
#include <dos.h>

extern unsigned short   _osmajor, _osminor;
extern unsigned short   _os_trueversion;
extern const    char  * _os_flavor;

unsigned short _get_dos_version(int true_version);

Description

This function gets the host OS version and flavor. If the argument true_version is non-zero, it will return a true version number, which is unaffected by possible tinkering with SETVER TSR program. (This is only available in DOS 5.0 or later.)

The external variables _osmajor and _osminor will always be set to the major and minor parts of the advertised version number. The external variable _os_trueversion will always be set to the true version number. _osmajor, _osminor and _os_trueversion may possibly be changed by SETVER, even if true_version is non-zero.

You typically need the true version when you need an intimate knowledge of the host OS internals, like when using undocumented features. Note that some DOS clones (notably, DR-DOS) do not support DOS function required to report the true DOS version; for these, the version reported might be affected by SETVER even if true_version is non-zero.

The external variable _os_flavor will point to a string which describes the OEM name of the host OS variety.

Return Value

_get_dos_version() returns the version number (true version number, if true_version is non-zero) as a 16-bit number: the major part of the version in the upper 8 bits, the minor part in the lower 8 bits. For instance, DOS version 6.20 will be returned as 0x0614.

Portability

ANSI/ISO C No
POSIX No

Example

 
  unsigned short true_dos_version = _get_dos_version(1);

  if (true_dos_version < 0x0614)   /* require DOS 6.20 or later */
    puts("This program needs DOS 6.20 or later to run");
  else
    printf("You are running %s variety of DOS\n", _os_flavor);


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004