TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KEVIN CAMPBELL
from: MAX BADRAK
date: 1997-03-31 01:08:00
subject: MS-DOS Env.

Hello, Kevin!
 KC> Does anyone know how to inset information into the environment block
 KC> (eg: SET Bob=C:\Bob\), inside a C++ program in a way that the
 KC> information will remain, even when the program exits, or, the program
 KC> quits using dos_keep() (a TSR).
 TC> I suggest you read SNIPPETS ENVIRON.TXT file. That will give you
 TC> more info. Its kind of impossible to do, unless you're willing to
 TC> back up and rewrite the user's AUTOEXEC.BAT file to reflect the
 TC> change and have the user reboot. That's about the only way I can
 TC> see it would work.
There is an undocumented way to obtain pointer to the MS-DOS "master" 
environment. I've used it to set PATH variable to length more than 128 bytes. 
And it works. At least under MS-DOS 6.22.
The idea comes from "UNDOCUMENTED DOS" by 
Andrew Schulman
andrew@pharlap.com
uunet!pharlap!andrew
CIS: 76320,302
(files last updated at 23 January 1990)
And here is the part of my source:
-------------------
   REGS r1;
   SREGS r2;
   r1.x.ax=0x352e;
   int86x(0x21,&r1,&r1,&r2);
   int E2VectSeg=r2.es;
   unsigned *EnvSegPointer=(unsigned *)MK_FP(E2VectSeg,0x002c);
   char *EnvPointer=(char *)MK_FP(*EnvSegPointer,0); /*pointer to master 
environment */
   unsigned EnvSize=(*(int *)MK_FP(*EnvSegPointer-1,3))*0x10; //size of 
master environment according to its MCB */
-------------------
I hope it will help.
Good bye.
                                                     Max 
--- 
---------------
* Origin: (2:463/321.1023)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.