en:docs:fapi:dosgetversion

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:docs:fapi:dosgetversion [2018/08/31 11:08]
prokushev created
en:docs:fapi:dosgetversion [2021/10/17 08:28] (current)
prokushev
Line 1: Line 1:
-This call returns the OS/2 version number.+{{page>​en:​templates:​fapiint}}
  
-==Syntax== +====== DosGetVersion ​======
- DosGetVersion ​(VersionWord)+
  
-==Parameters== +This call returns ​the OS version number.
-;​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== +===== Syntax =====
- rc (USHORT) - return +
-Return code description is: +
-* 0 NO_ERROR+
  
-==Remarks== +<code c> 
-This function has been eliminated since OS/2 2.0.+DosGetVersion (VersionWord) 
 +</code>
  
-==Bindings== +===== Parameters ​=====
-===C=== +
-<​PRE>​ +
-#define INCL_DOSMISC+
  
-USHORT ​ rc = DosGetVersion(VersionWord);​ +  * VersionWord ​([[PUSHORT]]- output:​Address of the OS version number. The version is stored as two bytes, with the minor version in the first byte and major version in the second byte.
-PUSHORT VersionWord; ​  ​/Version number ​(returned*/ +
-USHORT ​ rc;            /* return code */ +
-</​PRE>​+
  
-===MASM=== +===== Return Code =====
-<​PRE>​ +
-EXTRN DosGetVersion:​FAR +
-INCL_DOSMISC ​ EQU 1+
  
-PUSH@  WORD    VersionWord ​  ​;Version number(returned+  ​* rc ([[USHORT]]- return 
-CALL   ​DosGetVersion+   
 +Return code description is:
  
-Returns WORD +  * 0 NO_ERROR
-</​PRE>​+
  
-==Example== +===== Bindings =====
-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>​ +
-#define INCL_DOS +
-#include <​os2.h>​ +
-#define ENVVARNAME "​PATH"​+
  
-main() +==== C ==== 
-{ +<code c> 
-  ​SEL       ​EnvSel; ​       /* Environment segment selector (returned) */ +  #define INCL_DOSMISC 
-  USHORT ​   ​CmdOffset; ​    /* Offset into env. seg. of command line (returned*/ +   
-  PSZ FAR   ​*Commandline /* Pointer made by EnvSel and CmdOffset */ +  USHORT ​ rc = DosGetVersion(VersionWord); 
-  ​USHORT ​   Version      ​/* Version ​numbers ​(returned) */ +  ​PUSHORT VersionWord  ​/* Version ​number ​(returned) */ 
-  ​BYTE      MajorVer; ​     /* Major version number */ +  ​USHORT ​ ​rc; ​           /* return code */ 
-  BYTE      MinorVer; ​     /* Minor version number */ +</​code>​
-  USHORT ​   ​rc;            /* return code */+
  
-  /** Locate environment segment and offset of command line. **/+==== MASM ====
  
-  ​if(!(rc=DosGetEnv(&​EnvSel, ​      /* Env. seg. selector ​(returned) ​*/ +<code asm> 
-                    &​CmdOffset))) ​ /* Offset of command line +  EXTRN DosGetVersion:​FAR 
-                                           (returned) *+  INCL_DOSMISC ​ EQU 1 
-    ​printf("​Environment located; selector is %x offset is %x\n", EnvSel, +   
-            CmdOffset);+  PUSH@  WORD    VersionWord ​  ​;Version number(returned) 
 +  ​CALL   ​DosGetVersion 
 +</code> 
 +Returns WORD
  
-  /** Use a macro to make a far pointer out of selector:​offset pair.**/ +==== Example ====
-  /** 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**/ +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 lineIt then obtains the OS version ​number and prints it.
-  /** We need to divide by 10 to obtain true version ​numbers   **/+
  
-  if(!(rc=DosGetVersion(&​Version)))+<code c> 
 +  #define INCL_DOS 
 +  #include <​os2.h>​ 
 +  #define ENVVARNAME "​PATH"​ 
 +   
 +  main()
   {   {
-    MajorVer = HIBYTE(Version) / 10; +    ​SEL       ​EnvSel; ​       /* Environment segment selector (returned) */ 
-    MinorVer = LOBYTE(Version) / 10; +    USHORT ​   CmdOffset; ​    /* Offset into env. seg. of command line (returned) */ 
-    printf("​This is OS/2 version %d.%d\n",​ MajorVer, MinorVer);+    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); 
 +    }
   }   }
-+</code>
-</PRE> +
- +
  
-====== Note ======+===== Note =====
  
 Text based on [[http://​www.edm2.com/​index.php/​DosGetVersion]] Text based on [[http://​www.edm2.com/​index.php/​DosGetVersion]]

en/docs/fapi/dosgetversion.1535706481.txt.gz · Last modified: 2018/08/31 11:08 by prokushev