vbdpss.hlp (Table of Contents; Topic list)
Article Q82002
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Using ENVIRON$ to Detect If Program Is Running Under Windows - Q82002
 
 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 ENVIRON$ function.
 
 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. Listed below is a sample program that performs this type
 of functionality.
 
 Example Code
 ------------
 
 ' To try this example in VBDOS.EXE:
 ' 1. From the File menu, choose New Project.
 ' 2. Copy the code example to the Code window.
 ' 3. Press F5 to run the program.
 
 IF ENVIRON$("windir") <> "" THEN
     PRINT "running under Windows"
 ELSE
     PRINT "not running under Windows"
 END IF