...
This string should be referenced immediately and discarded, or copied so that the copy may be referenced safely at a later time. The getenv() function is not thread-safe. Make sure to address any possible race conditions resulting from the use of this function.
Implementation Details
According to the Microsoft Visual Studio 2005/.NET Framework 2.0 help pages:
The
getenvfunction searches the list of environment variables forvarname.getenvis not case sensitive in the Windows operating system.getenvand_putenvuse the copy of the environment pointed to by the global variable_environto access the environment.getenvoperates only on the data structures accessible to the run-time library and not on the environment "segment" created for the process by the operating system. Therefore, programs that use theenvpargument tomainorwmainmay retrieve invalid information.
Non-Compliant Code Example
...