WinMetrics and WinVersion Returning Incorrect Values
Keywords: Winversion Winmetrics Netware NetInfo 3.10
Known Problems:
- The function WinMetrics(-4) incorrectly returns a 0 for Windows 3.10 and 3.11 when Netware is running. As a workaround, use a NetInfo also, as in the example below:
wm = WinMetrics(-4) If wm != 5 ; Windows 3.1x If wm == 0 ni0 = NetInfo(0) ni1 = NetInfo(1) If ni0 == "MULTINET" || ni1 == "WINNET" ; Do Some Processing Here EndIf Drop(ni0, ni1) EndIf Else ; Do Some Processing Here EndIf Drop(wm)
- The WinVersion function in the 16 bit version of WinBatch always returns 3.10. It is the operating system's attempt to make the old 16 bit apps feel at home and not lost in some brave new world. The solution is the upgrade to the latest version of Winbatch (if you don't have it already), and use the Winmetrics(-4) function (see below).
In the 32 bit version of WinBatch, WinVersion will return a correct number.
To determine what version of Windows you're running when using the 32-bit version of Winbatch, use the WinVersion function, which will return the major and minor version numbers, as in:
;@MAJOR returns the integer part of the Windows version number; ;i.e. 1.0, 2.11, 3.0, etc. ;@MINOR returns the decimal part of the Windows version number; ;i.e. 1.0, 2.11, 3.0, etc. NTmajorver = WinVersion(@MAJOR) ;i.e. 3 or 4 NTminorver = WinVersion(@MINOR) ;i.e. 51 or 0 Message("Windows NT Version", StrCat(NTmajorver, ".", NTminorver))
- If you just need a sleazy hack to figure out NT v4.0 versus NT v3.51, you could just do something like:
if WinExist("Explorer") then it must be nt 4.0WinBatch not Reporting Correct Windows Version
Question:
The Winbatch WinVersion function is not returning the proper version of Windows (it should be 3.11 and NOT 3.10). Any Ideas?Answer:
WinBatch is indeed reporting the numbers as provided by the Windows API calls. There is a long complicated reason for this involving Microsoft only licensing Novell NetWare drivers for Windows version 3.10, but nothing else, so Windows 3.11 appears internally as something like Version 3.10 SubVersion 1.WinVersion function under NT 3.51:
The 32 bit version of WinBatch returns the correct Windows version under NT (i.e., 3.51).
However, the 16-bit version of WinBatch returns 3.10 under NT. The reason for this is that Windows NT is "emulating" Windows 3.1 for 16-bit applications.
If you're trying to determine is a platform is either 16 or 32 bit, then use the WinMetrics function, with the -4 request code. There are nice examples elsewhere on this website on how to use WinMetrics to determine the platform, and thereafter launch the appropriate compiled EXE depending on that result.
Article ID: W12725Filename: WinMetrics Incorrect Return and Winversion Tips.txt