RE: SetEnvironmentVariable in Debug and Release cofiguratin

Tech-Archive recommends: Fix windows errors by optimizing your registry



>From the Platform SDK
--------------------------

Calling SetEnvironmentVariable has no effect on the system environment
variables. The user can add or modify system environment variables using the
Control Panel. To programmatically add or modify system environment
variables, add them to the
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session
Manager\Environment registry key, then broadcast a WM_SETTINGCHANGE message.
This allows applications, such as the shell, to pick up your updates.

So, my next question is this ... how are you checking for your environment
variable, are you doing it programatically (calling GetEnvironmentVariable)
or are you trying to find it in the EnvironmentVariables tab of the control
panel, etc.

You will not be able to see the variable in your system environment
variables (via the control panel) every PROCESS has an environment block that
contains a set of environment variables and their values, you will have to
inspect these environment variables programatically.

I hope that helps.

:o))



--
--

Of all words of tongue and pen, the saddest are: "It might have been"


"denis.greatest@xxxxxxxxx" wrote:

> Hello folks,
>
> I was trying to set some environment variable for a process I create.
> (The variables are my own, not system).
>
> I use SetEnvironmentVaraible() from C# code.
> In Debug configuration this works fine, but in Release configuration
> the action fails.
> The return value is TRUE, and no Exception is thrown.
>
> Any ideas ?!
>
>
.



Relevant Pages

  • Re: GenEnvironmentVariable and CreateProcess failures under XP
    ... environment variable was not found in the environment block. ... If you first call GetEnvironmentVariable with a 0-length string, ... It does not affect the "system environment" that other ... CreateProcess to launch Notepad or other Win32 executables. ...
    (microsoft.public.vb.winapi)
  • Re: odd behavior on client installation
    ... And being an environment variable, ... keys, *AND* clean up the system environment ... expecting, leading to my purge of Oracle from the system being ... presence of environment settings being set from places I had never ...
    (comp.databases.oracle.server)
  • Re: Urgent...... Issues with GetEnvironmentVariable( ) on Win2k PRO SP4
    ... it inherits its environment at boot time from the Service ... which has only the values of the System Environment ... if anything is defined or else goto the registery to get the ... For an appln started from the shell, ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Unable to access system environment variables under IIS 6
    ... Changing system environment variable requires rebooting the server for it ... launch CMD.EXE from the Start Menu's ...
    (microsoft.public.inetserver.iis)
  • Re: Error message concerning DOSX.exe
    ... There might be a problem with the Path statement in your Environment ... Open the System applet in Control Panel, ... "System Error: ...
    (microsoft.public.windowsxp.general)