Microsoft KB Archive/113998

= PRB: GetVersion API Returns 3.10 When in Windows 3.11 =

Article ID: 113998

Article Last Modified on 1/8/2003

-

APPLIES TO


 * Microsoft Visual Basic 3.0 Professional Edition

-



This article was previously published under Q113998



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.



Step-by-Step Example
 Start a new project in Visual Basic. Form1 is created by default.  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$)   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  Run the application by pressing the F5 key.

Additional query words: 3.00

Keywords: kbprb KB113998

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.