Carl Daniel [VC++ MVP]
2004-06-22 18:17:18 UTC
I am using VC++ developed in MS Visual Studio. I can get the value
of an environmnent variable using GetEnvironmentVariable(...). The
trouble is when running from the debugger in VS it is the original
value sent to MS when it first started. How can I refresh the
Environment Variables at runtime within the application.
On reading this question several times, I think you're asking: "How can Iof an environmnent variable using GetEnvironmentVariable(...). The
trouble is when running from the debugger in VS it is the original
value sent to MS when it first started. How can I refresh the
Environment Variables at runtime within the application.
make my program see environment changes made outside the development
environment when I run my program under the debugger". If that's what
you're asking, I believe the answer is "you can't".
Another reading of this question might be "How can I make the debugger see
environment variable changes that I make in my program". If that's not the
question you're asking, please ask again!
In general, you can't change the environment of another process. Each
running process has it's own copy of the environment that's created with the
process. In order to change the environment of another running process,
that process must provide some facility for you to use - there's no
system-supplied way to tinker with another process's environment (imagine
the gigantic security hole that would be!).
That said, some applications, including Explorer.exe will reload their
environment from the registry if you send a WM_SETTINGCHANGE with
LPARAM="Registry". I have no idea if devenv.exe listens to
WM_SETTINGCHANGE, but I would NOT expect it to.
-cd