XL: Reading the MS-DOS Environment StringID: Q69725
|
It is possible to retrieve a set of characters from the MS-DOS environment string from Microsoft Excel if you are running under Microsoft Windows 3.0. This is done using the CALL and REGISTER functions.
The DOS environment is an area of memory that MS-DOS sets aside to store a
series of ASCII strings. Each string in the environment is terminated by a
byte of zero. The final string is terminated by two bytes of zero.
The following Microsoft Excel macro function will return the first N number
of characters (starting with the second character) from the DOS environment
string, including the zero bytes separating strings. This occurs as long as
the first character in your environment string has the ASCII decimal value
of N.
A1 Get_Environment
A2 =REGISTER("KERNEL","GetMS-DOSEnvironment","D")
A3 =CALL(A2)
A4 =RETURN()
NOTE: The CALL function can also be used on a standard worksheet in
Microsoft Excel version 3.0.
USERNAME=BOB{null}
where {null} indicates the zero byte terminating the string. This is
because the ASCII tilde character "~" has a decimal value of 126. You can
then search this string for particular environment variables.
"Online Help," version 5.0
"Function Reference," version 4.0, pages 42-43, 350-352, 475-480
"Function Reference," version 3.0, pages 24, 193-194, 253-258
"Functions and Macros," version 2.1x, pages 255-256 and 337-340
Additional query words: 2.1 2.10 3.0 3.00 4.0 4.00 5.0 5.00 environment variable
Keywords :
Version : 2.x 3.x 4.00 5.00
Platform : WINDOWS
Issue type :
Last Reviewed: July 23, 1999