As you say I'm not really ran the code below. I'm sorry!
You are completely right.

There is link to explanation and code which *I'm tested* and works well
on XP SP2:  http://dn.codegear.com/article/28254

Branko

There is link to 
  ----- Original Message ----- 
  From: Rob Kennedy 
  To: [email protected] 
  Sent: Saturday, August 16, 2008 11:01 PM
  Subject: Re: [delphi-en] Re: Set Environment Variable from Delphi Console App


  Branko BURDIAN wrote:
  > Simple example;
  > 
  > program SetEnv;
  > {$APPTYPE CONSOLE}
  > uses
  > Windows;
  > procedure SetEnvVariable(const AName, AValue: string);
  > begin
  > if Trim(AValue) = '' then
  > SetEnvironmentVariable(PChar(AName), nil)
  > else
  > SetEnvironmentVariable(PChar(AName), PChar(AValue));
  > end;
  > begin
  > SetEnvVariable('foobar', 'abcdef');
  > end;
  > 
  > Compile and run program:
  > 
  > C:\>SetEnv <Enter>
  > C:\>set foobar <Enter>
  > foobar=abcdes <= This is the result of "set foobar" command
  > 
  > Result of runing program SetEnv is same as if you execute
  > "set foobar=abcdef" (without ") on command prompt!!

  Are you sure about that?

  I don't think you actually ran the code you show above.

  Each process inherits a *copy* of its parent's environment. 
  Modifications to the environment are not propagated back to the parent 
  process. When you run SetEnv, it does not modify the environment of 
  cmd.exe. The "set" command is a built-in command of cmd.exe, so when you 
  use it, you're making cmd.exe modify its own environment. Batch files, 
  likewise, are executed by the command interpreter, not by a separate 
  process, so batch files can modify the environments of the processes 
  that execute them.

  -- 
  Rob


   

  __________ NOD32 3361 (20080816) Informacija __________

  To sporo�ilo je preveril protivirusni sistem NOD32.
  http://www.nod32.com


[Non-text portions of this message have been removed]

Reply via email to