Microsoft KB Archive/82002

From BetaArchive Wiki
Knowledge Base


Article ID: 82002

Article Last Modified on 8/16/2005



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1
  • Microsoft Cinemania 97 Standard Edition
  • Microsoft Windows 3.0 Standard Edition
  • Microsoft Windows 3.1 Standard Edition
  • Microsoft GW-BASIC Interpreter 3.20
  • Microsoft GW-BASIC Interpreter 3.23
  • Microsoft GW-BASIC Interpreter 3.22
  • Microsoft GW-BASIC Interpreter 3.23



This article was previously published under Q82002

SUMMARY

A Microsoft Basic program can detect whether it is running under Microsoft Windows by checking for the existence of the environment variable "windir" with the function ENVIRON$.

This information applies to Microsoft QuickBasic versions 4.0, 4.0b, and 4.5 for MS-DOS; Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS; Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS; Microsoft GW-Basic Interpreter versions 3.2, 3.22, and 3.23 for MS-DOS; and Microsoft Windows versions 3.0 and 3.1.

MORE INFORMATION

When Windows runs a program, it supplies the environment variable named "windir" that specifies the full path of the directory where Windows is installed. Note that this environment variable name is spelled with lowercase letters.

If a Basic program is running under Microsoft Windows, the expression ENVIRON$("windir") returns a non-null string, otherwise it returns a null string.

Example Code

IF ENVIRON$("windir") <> "" THEN
    PRINT "running under Windows"
ELSE
    PRINT "not running under Windows"
END IF
                


Additional query words: QuickBas BasicCom 3.00 3.10 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10

Keywords: KB82002