PRB: GetVersion API Returns 3.10 When in Windows 3.11

Last reviewed: June 21, 1995
Article ID: Q113998
The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0

SYMPTOMS

The GetVersion Windows API function returns version 3.10 when in Windows version 3.11.

CAUSE

GetVersion still returns 3.10 while inside Windows for Workgroups version 3.11 because there were so many applications that were checking for the version number and requiring that the application be run under version 3.10. Therefore, Microsoft decided to have the GetVersion function continue to return version 3.10 in Windows version 3.11.

WORKAROUND

To look for Windows version 3.11 from within Windows, use the GetFileVersionInfo Windows API function instead of GetVersion. This article shows by example how to call GetFileVersionInfo from Visual Basic.

STATUS

This behavior is by design to help developers who have developed applications that required and checked for Windows version 3.10.

MORE INFORMATION

Step-by-Step Example

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add the following code to the general declarations section of Form1:

       ' Enter the following Declare statement as one, single line:
       Declare Function GetFileVersionInfo% Lib "VER.DLL" (ByVal lpszFileName$,
          ByVal handle As Any, ByVal cbBuf&, ByVal lpvData$)
    
    

  3. Add the following code to the Form_Load event of Form1:

       Sub Form_Load ()
          Dim pos As Integer
          Dim version As String * 255
          Dim ans As String
          version = Space$(255)
          ' Get the version info and fill the version string:
          ret% = GetFileVersionInfo("user.exe", 0&, 254, version)
          ' Find the position in the string where the FileVersion stamp is:
          pos = InStr(1, version, "FileVersion")
          ' 12 is the length of "FileVersion" +1 for the null
          ' 4 is the length of string (3.11 in this case) to return
          ans = Mid$(version, pos + 12, 4)
          ' Display the answer:
          MsgBox ans
       End Sub
    
    

  4. Run the application by pressing the F5 key.


Additional reference words: 3.00
KBCategory: kbprg kbcode kbprb
KBSubcategory: APrgOther


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.