Environment variables for dll are different than exe

I am debugging a 64-bit application where C # exe uses the native C ++ dll on Windows 7. It seems environment variables are different for the two, although they are both executed in the same process. How is it possible that a call to System.Environment.SetEnvironmentVariable does not affect the values ​​returned by getenv ()?

+3
source share
2 answers

Environment variables are just a piece of data that is passed to the Windows process when it starts. The run-time functions used (BCL for System.Environment and CRT for getenv) are likely to create copies of the environment at startup, which means that they do not work with the same environment variables.

, - .

+6

. EnvironmentVariableTarget http://msdn.microsoft.com/en-us/library/system.environmentvariabletarget.aspx .

public SetEnvironmentVariable (    ,    ,    EnvironmentVariableTarget )

0

Source: https://habr.com/ru/post/1795459/


All Articles