Jump to content

DosGetVersion: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Ak120 (talk | contribs)
mNo edit summary
Line 1: Line 1:
[[image:legacy.png]]
This function has been eliminated since OS/2 2.0 [https://books.google.com.ec/books?id=u7WbsmbttwYC&pg=PT372&lpg=PT372&dq#v=onepage&q&f=false]
==Description==
This call returns the OS/2 version number.
This call returns the OS/2 version number.


==Syntax==
==Syntax==
<PRE>
  DosGetVersion (VersionWord)
  DosGetVersion
 
    (VersionWord)
</PRE>
==Parameters==
==Parameters==
; VersionWord (PUSHORT) - output : Address of the OS/2 version number. The version is stored as two bytes, with the minor version in the first byte and major version in the second byte.
;VersionWord (PUSHORT) - output : Address of the OS/2 version number. The version is stored as two bytes, with the minor version in the first byte and major version in the second byte.


==Return Code==
==Return Code==
  rc (USHORT) - return
  rc (USHORT) - return
Return code description is:
Return code description is:
* 0    NO_ERROR
* 0    NO_ERROR


==Remarks==
==Remarks==
 
This function has been eliminated since OS/2 2.0


==Example Code==
==Example Code==
Line 30: Line 20:


USHORT  rc = DosGetVersion(VersionWord);
USHORT  rc = DosGetVersion(VersionWord);
 
PUSHORT VersionWord;  /* Version number (returned) */
PUSHORT         VersionWord;  /* Version number (returned) */
USHORT rc;            /* return code */
 
USHORT           rc;            /* return code */
</PRE>
</PRE>


Line 39: Line 27:


The following example shows how one may obtain information for program initialization. The program locates the environment segment and prints the name of the command from the command line. It then obtains the OS/2 version number and prints it.  
The following example shows how one may obtain information for program initialization. The program locates the environment segment and prints the name of the command from the command line. It then obtains the OS/2 version number and prints it.  
<PRE>
<PRE>
#define INCL_DOS
#define INCL_DOS
#include <os2.h>
#include <os2.h>
#define ENVVARNAME "PATH"
#define ENVVARNAME "PATH"


main()
main()
{
{
   SEL      EnvSel;             /* Environment segment selector
   SEL      EnvSel;       /* Environment segment selector (returned) */
                                    (returned) */
   USHORT    CmdOffset;     /* Offset into env. seg. of command line (returned) */
   USHORT    CmdOffset;           /* Offset into env. seg. of command line
   PSZ FAR  *Commandline; /* Pointer made by EnvSel and CmdOffset */
                                    (returned) */
   USHORT    Version;       /* Version numbers (returned) */
   PSZ FAR  *Commandline;       /* Pointer made by EnvSel and CmdOffset */
   BYTE      MajorVer;     /* Major version number */
   USHORT    Version;             /* Version numbers (returned) */
   BYTE      MinorVer;     /* Minor version number */
   BYTE      MajorVer;           /* Major version number */
   USHORT    rc;           /* return code */
   BYTE      MinorVer;           /* Minor version number */
   USHORT    rc;                 /* return code */


   /** Locate environment segment and offset of command line. **/
   /** Locate environment segment and offset of command line. **/
Line 94: Line 77:
Returns WORD
Returns WORD
</PRE>
</PRE>
==Related Functions==
*


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Revision as of 18:08, 25 February 2017

This call returns the OS/2 version number.

Syntax

DosGetVersion (VersionWord)

Parameters

VersionWord (PUSHORT) - output
Address of the OS/2 version number. The version is stored as two bytes, with the minor version in the first byte and major version in the second byte.

Return Code

rc (USHORT) - return

Return code description is:

  • 0 NO_ERROR

Remarks

This function has been eliminated since OS/2 2.0

Example Code

C Binding

#define INCL_DOSMISC

USHORT  rc = DosGetVersion(VersionWord);
PUSHORT VersionWord;   /* Version number (returned) */
USHORT  rc;            /* return code */

Example

The following example shows how one may obtain information for program initialization. The program locates the environment segment and prints the name of the command from the command line. It then obtains the OS/2 version number and prints it.

#define INCL_DOS
#include <os2.h>
#define ENVVARNAME "PATH"

main()
{
  SEL       EnvSel;        /* Environment segment selector (returned) */
  USHORT    CmdOffset;     /* Offset into env. seg. of command line (returned) */
  PSZ FAR   *Commandline;  /* Pointer made by EnvSel and CmdOffset */
  USHORT    Version;       /* Version numbers (returned) */
  BYTE      MajorVer;      /* Major version number */
  BYTE      MinorVer;      /* Minor version number */
  USHORT    rc;            /* return code */

  /** Locate environment segment and offset of command line. **/

  if(!(rc=DosGetEnv(&EnvSel,       /* Env. seg. selector (returned) */
                    &CmdOffset)))  /* Offset of command line
                                           (returned) */
    printf("Environment located; selector is %x offset is %x\n", EnvSel,
            CmdOffset);

  /** Use a macro to make a far pointer out of selector:offset pair.**/
  /** Notice the far-string pointer specification (%Fs) used to print **/

  Commandline = MAKEP(EnvSel, CmdOffset);
  printf("Command entered is %Fs.\n", Commandline);

  /** Obtain and print version info; use macros to extract info. **/
  /** We need to divide by 10 to obtain true version numbers.    **/

  if(!(rc=DosGetVersion(&Version)))
  {
    MajorVer = HIBYTE(Version) / 10;
    MinorVer = LOBYTE(Version) / 10;
    printf("This is OS/2 version %d.%d\n", MajorVer, MinorVer);
  }
}

MASM Binding

EXTRN  DosGetVersion:FAR
INCL_DOSMISC      EQU 1

PUSH@  WORD    VersionWord   ;Version number(returned)
CALL   DosGetVersion

Returns WORD