BUG: OS() Function Returns Incorrect Value Under Windows NT 4.0Last reviewed: October 2, 1997Article ID: Q174561 |
The information in this article applies to:
SYMPTOMSThe OS() function returns incorrect operating system information when executed from FoxPro for Windows 2.6x or FoxPro for MS-DOS 2.6x running under Windows NT 4.0. The OS() function returns the value DOS 05.00 for the MS-DOS version. Adding the "1" switch available in the OS() function under FoxPro for Windows 2.6x should report the current version of Windows. When running under Windows NT 4.0, the OS(1) function incorrectly identifies the Windows version as Windows 3.10
RESOLUTIONIn FoxPro for Windows 2.6x, you can use the GetWinFlags API to determine whether the application is running on Windows NT 4.0. The code example sends a message to the FoxPro desktop indicating whether Windows NT is the current operating system. It does not include the version of NT. Since the code includes Windows API calls, it will not work in FoxPro for MS-DOS.
**** Begin Code Example**** CLEAR SET LIBRARY TO home() + "foxtools.fll" * WF-WINNT represented as the 0-based bit number that must be on * in the returned WinFlags() for the program to be running under NT. WF_WINNT = 14 m.getwinflags = RegFN("GetWinFlags", "", "L") m.retval = callfn(m.getwinflags) IF testbit(m.retval, WF_WINNT) ? "Running NT" ELSE ? "Not running NT" ENDIF ***************** * function testbit - determines if a specific bit of a passed number is * on/off * * passed: number (m.number) * bit number (m.bitnum, 0 - 31) * * returns: .f. for off, .t. for on, .f. for illegal function call **************** FUNCTION testbit PARAMETERS m.number, m.bitnum * number too big - exit IF NOT BETWEEN(m.bitnum, 0, 31) RETURN .F. ENDIF m.ascii = m.number FOR i = 31 TO 0 STEP -1 m.newascii = MOD(m.ascii, 2 ^ i) IF m.bitnum = i IF m.newascii # m.ascii RETURN .T. ELSE RETURN .F. ENDIF ENDIF m.ascii = m.newascii NEXT **** End Code Example**** STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONThe OS() function differs slightly between FoxPro for MS-DOS and FoxPro for Windows 2.6x. In FoxPro for Windows, the OS() function has an optional parameter of 1. This returns the version of Windows. The OS() function simply returns the MS-DOS operating system version.
Steps to Reproduce Behavior
REFERENCESFor additional information, please see the following articles in the Microsoft Knowledge Base:
ARTICLE-ID: Q122353 TITLE : How to Determine If a VB App is Running Under Windows NT 3.x ARTICLE-ID: Q131371 TITLE : Determining System Version from a Windows-Based Application |
Additional query words: OS
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |