
Bug in retrieving environment variables via Getenvironmentvariable
First, make sure you have allocated enough space in your return string for
the entire set of environment strings (you probably have, 'cause you'd GPF
otherwise...).
The different environment strings are separated by ascii zeroes (with a
double-zero at the end of the whole mess). Many functions (such as
Debug.Print) will stop operating on a string when they encounter a zero
("C" strings are always terminated this way).
Use Instr(nStart, sMyEnviro, Chr$(0)) iteratively to find all the zeroes
and parse out the substrings.
Jim Deutch
MS Dev MVP
Quote:
> Help! I'm using VB5 under NT4 and have an app which needs to obtain DOS
> environment variables set using a DOS batch file. The DLL
> Getenvironmentvariable should be able to obtain them for me, however for
> some reason i can only retrieve the 'Path' environment variable not any
of
> my own i have set in my batch file. Any ideas?