delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/03/03:12:16

From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Setting DOS environment variables
Date: Thu, 3 Feb 2000 08:16:14 +0200
Organization: NetVision Israel
Lines: 21
Message-ID: <Pine.SUN.3.91.1000203081550.3341E-100000@is>
References: <22e8c8ce DOT 39f84b4f AT usw-ex0105-040 DOT remarq DOT com>
NNTP-Posting-Host: is.elta.co.il
Mime-Version: 1.0
X-Trace: news.netvision.net.il 949558760 5833 199.203.121.2 (3 Feb 2000 06:19:20 GMT)
X-Complaints-To: abuse AT netvision DOT net DOT il
NNTP-Posting-Date: 3 Feb 2000 06:19:20 GMT
X-Sender: eliz AT is
In-Reply-To: <22e8c8ce.39f84b4f@usw-ex0105-040.remarq.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Wed, 2 Feb 2000, wriska wrote:

> I am trying to set DOS environment variables from within a DJGPP
> C program, but I am not having much success.  Would someone
> please be kind enough to post a snippet of code that could do
> this?  I am looking for something to be flexible enough to allow
> for varying environment variable names as well as values.

There are library functions `setenv' and `putenv', look them up in the
library docs.  Their use is pretty much obvious; `putenv's docs
includes an example.

Btw, you aren't trying to change the environment of the shell from
which you run your programs, are you?  If that's what you are trying
to do, forget it: it's not possible.  Programs can only change the
environment of the child programs they invoke, not of their parents.

(Well, actually, it *is* possible to change the environment of the
parent shell, but it involves walking the DOS memory chain, which is
very complicated and totally unportable.)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019