Microsoft KB Archive/250512: Difference between revisions
(importing KB archive) |
m (Text replacement - """ to """) |
||
Line 12: | Line 12: | ||
<div id="TitleRow"> | <div id="TitleRow"> | ||
= <span id="KB250512"></span>PRB: OS() Function May Not Return | = <span id="KB250512"></span>PRB: OS() Function May Not Return "NT" Under Windows 2000 = | ||
Line 45: | Line 45: | ||
== SYMPTOMS == | == SYMPTOMS == | ||
Code that tests the return value for the string | Code that tests the return value for the string "NT" of the '''OS()''' function in Microsoft Visual FoxPro 6.0 Build 8492 or later operates incorrectly under Microsoft Windows 2000. | ||
</div> | </div> | ||
Line 52: | Line 52: | ||
== CAUSE == | == CAUSE == | ||
Because Windows 2000 is not designated as | Because Windows 2000 is not designated as "Windows NT," but is referred to as "built on NT Technology," the '''OS()''' function should no longer refer to it as "Windows NT 5.0." | ||
</div> | </div> | ||
Line 61: | Line 61: | ||
There are two workarounds for this issue: | There are two workarounds for this issue: | ||
<ul> | <ul> | ||
<li>Use the '''GetVersionEx''' Win32API call to return extended version information about Microsoft Windows, including the platform type. See the | <li>Use the '''GetVersionEx''' Win32API call to return extended version information about Microsoft Windows, including the platform type. See the "References" section for more information on this function.</li> | ||
<li><p>Use the following code to test all possible return values from '''OS()''' in a DO CASE block to see which version you are running. However, this might require that the code be rewritten with each major Windows release.</p> | <li><p>Use the following code to test all possible return values from '''OS()''' in a DO CASE block to see which version you are running. However, this might require that the code be rewritten with each major Windows release.</p> | ||
<pre class="codesample">Clear | <pre class="codesample">Clear | ||
Do Case | Do Case | ||
* Tests for Windows 2000 | * Tests for Windows 2000 | ||
Case | Case "5.00" $ OS() | ||
? | ? "Windows NT 5.0" | ||
Case | Case "NT 4.00" $ OS() | ||
? | ? "Windows NT 4.0" | ||
* Tests for Windows 95 | * Tests for Windows 95 | ||
Case | Case "4.00" $ OS() | ||
? | ? "Windows 95" | ||
* Tests for Windows 98 | * Tests for Windows 98 | ||
Case | Case "4.10" $ OS() | ||
? | ? "Windows 98" | ||
EndCase</pre></li></ul> | EndCase</pre></li></ul> | ||
Line 95: | Line 95: | ||
The following code is typically written in programs that use API calls specific to a given operating system: | The following code is typically written in programs that use API calls specific to a given operating system: | ||
<pre class="codesample">IF | <pre class="codesample">IF "NT" $ OS() | ||
*!* do NT-specific stuff | *!* do NT-specific stuff | ||
ELSE | ELSE | ||
Line 101: | Line 101: | ||
ENDIF | ENDIF | ||
</pre> | </pre> | ||
However, when testing for the presence of a particular feature, it is better to use the '''GetProcAddress''' API call. See the | However, when testing for the presence of a particular feature, it is better to use the '''GetProcAddress''' API call. See the "References" section for more information. | ||
=== Steps to Reproduce Behavior === | === Steps to Reproduce Behavior === | ||
# Run Visual FoxPro 6.0 Service Pack 3 under Windows NT 4.0. Type <span class="kbd userinput"> ? OS()</span> in the '''Command''' window, and note that it prints | # Run Visual FoxPro 6.0 Service Pack 3 under Windows NT 4.0. Type <span class="kbd userinput"> ? OS()</span> in the '''Command''' window, and note that it prints "Windows NT 4.0." | ||
# Run Visual FoxPro 6.0 (no service pack) under Windows 2000. Type <span class="kbd userinput"> ? OS() </span> in the '''Command''' window, and note that it prints | # Run Visual FoxPro 6.0 (no service pack) under Windows 2000. Type <span class="kbd userinput"> ? OS() </span> in the '''Command''' window, and note that it prints "Windows NT 5.0." | ||
# Run Visual FoxPro 6.0 Service Pack 3 under Windows 2000. Type <span class="kbd userinput"> ? OS()</span> in the '''Command''' window, and note that it prints | # Run Visual FoxPro 6.0 Service Pack 3 under Windows 2000. Type <span class="kbd userinput"> ? OS()</span> in the '''Command''' window, and note that it prints "Windows 5.0." | ||
Latest revision as of 13:51, 21 July 2020
Article ID: 250512
Article Last Modified on 10/15/2003
APPLIES TO
- Microsoft Visual FoxPro 6.0 Professional Edition, when used with:
- Microsoft Visual Studio 6.0 Service Pack 3
This article was previously published under Q250512
SYMPTOMS
Code that tests the return value for the string "NT" of the OS() function in Microsoft Visual FoxPro 6.0 Build 8492 or later operates incorrectly under Microsoft Windows 2000.
CAUSE
Because Windows 2000 is not designated as "Windows NT," but is referred to as "built on NT Technology," the OS() function should no longer refer to it as "Windows NT 5.0."
RESOLUTION
There are two workarounds for this issue:
- Use the GetVersionEx Win32API call to return extended version information about Microsoft Windows, including the platform type. See the "References" section for more information on this function.
Use the following code to test all possible return values from OS() in a DO CASE block to see which version you are running. However, this might require that the code be rewritten with each major Windows release.
Clear Do Case * Tests for Windows 2000 Case "5.00" $ OS() ? "Windows NT 5.0" Case "NT 4.00" $ OS() ? "Windows NT 4.0" * Tests for Windows 95 Case "4.00" $ OS() ? "Windows 95" * Tests for Windows 98 Case "4.10" $ OS() ? "Windows 98" EndCase
STATUS
This behavior is by design.
MORE INFORMATION
The following code is typically written in programs that use API calls specific to a given operating system:
IF "NT" $ OS() *!* do NT-specific stuff ELSE *!* do Win 9x-specific stuff ENDIF
However, when testing for the presence of a particular feature, it is better to use the GetProcAddress API call. See the "References" section for more information.
Steps to Reproduce Behavior
- Run Visual FoxPro 6.0 Service Pack 3 under Windows NT 4.0. Type ? OS() in the Command window, and note that it prints "Windows NT 4.0."
- Run Visual FoxPro 6.0 (no service pack) under Windows 2000. Type ? OS() in the Command window, and note that it prints "Windows NT 5.0."
- Run Visual FoxPro 6.0 Service Pack 3 under Windows 2000. Type ? OS() in the Command window, and note that it prints "Windows 5.0."
REFERENCES
For additional information about the GetVersionEx API call, click the article number below to view the article in the Microsoft Knowledge Base:
188987 HOWTO: Determine the Operating System Build Number
For additional information about calling the GetProcAddress function, click the article number below to view the article in the Microsoft Knowledge Base:
193573 HOWTO: Determine the Version of a DLL
Keywords: kbbug kbxbase kbprb KB250512