include vmm.inc
mov esi, OFFSET32 Variable ; environment variable name
VMMCall Get_Environment_String
jc not_found ; carry set if variable not found
mov [Value], edx ; addr. of null-terminated string
Returns the value of the specified environment variable. For Windows 95, this service is available following initialization. Uses EDX, Flags.
Environment variables, set using the MS-DOS set command, are a limited resource. Although some virtual devices use environment variables as a way to set operating parameters, this is not recommended unless the variable is used by a set of programs, MS-DOS device drivers, and virtual devices.
When zero is passed as the name of the environment variable, a pointer to the 'global environment' is returned in the EDX register. The global environment has the same format as in MS-DOS: A packed array of zero-terminated ASCII strings, each of the form '<variable>=<value>', all terminated by an extra null byte. The VMM also creates a fake 16-byte MS-DOS arena header in front of the environment block so that you can determine its size:
GLOBAL_ENVIRONMENT_HEADER struc
db 'M'
dw 0FFFFh
dw paraSize ; Size in paragraphs, not incl. header
db 11 dup (?) ; Padding
GLOBAL_ENVIRONMENT_HEADER ends
Do not attempt to resize the environment. You may, however, edit the environment, provided you do so during system initialization. Changes to the global environment after system initialization will not take effect the way you expect.
Do not keep pointers into the global environment. The global environment moves around during the running of the system, so any pointer you keep into it may be stale by the time you use it. If you need to retain the value of an environment variable, make a private copy.