home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / win_lrn / version.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  1.5 KB  |  46 lines

  1. /*
  2.  *  GetVersion
  3.  *  version.c
  4.  *
  5.  *  This function returns the current version of windows in an unsigned
  6.  *   short integer.  The low byte corresponding to the major version
  7.  *   number and the high byte corresponding to the minor version number.
  8.  *  This function calls the GetVersion function and places the version
  9.  *   number in a message box with the appropriate bytes to convey the
  10.  *   actual current version number.
  11.  *
  12.  */
  13.  
  14. #include <windows.h>
  15.  
  16. int PASCAL WinMain(hInstance, hPrevInstance, lpszCmdLine, cmdShow)
  17. HANDLE hInstance, hPrevInstance;
  18. LPSTR lpszCmdLine;
  19. int cmdShow;
  20.  
  21. {
  22.    unsigned short version;       /* The Current Version Number.    */
  23.    unsigned short majvers;       /* The Major Version Number.      */
  24.    unsigned short minvers;       /* The Minor Version Number.      */
  25.    char szbuf[14];              /* The Version Number Buffer.     */
  26.  
  27.    version = GetVersion();       /* Get the Current Version.        */
  28.    majvers = LOBYTE(version);    /* Cast Major Version.              */
  29.    minvers = HIBYTE(version);    /* Cast the Minor Version.           */
  30.    sprintf(szbuf,             /* Place the version number in    */
  31.            "%9s%1d%1s%02d",   /*  the output buffer along with  */
  32.            " Version ",       /*  some explatitory text.        */
  33.            majvers,
  34.            ".",
  35.            minvers);
  36.  
  37.                    /* Create Version Number Message. */
  38.  
  39.    MessageBox(NULL, (LPSTR)szbuf, (LPSTR)"MS-Windows", MB_OK);
  40.  
  41.                    /* Print Out Version Message.     */
  42.  
  43.    return 0;               /* Exit With a Successful Return. */
  44.  
  45. }
  46.