在C++中设置本地环境变量

2023-12-21

如何在 C++ 中设置环境变量?

  • 他们不需要保留过去的程序执行
  • 它们只需要在当前进程中可见
  • 偏好与平台无关,但对于我的问题,只需要在 Win32/64 上工作

Thanks




NAME

       putenv - change or add an environment variable

SYNOPSIS

       #include &ltstdlib.h;>

       int putenv(char *string);

DESCRIPTION
       The  putenv()  function adds or changes the value of environment
       variables.  The argument string is of the form name=value.  If name does
       not already exist in the environment, then string is added  to  the
       environment.   If name does exist, then the value of name in the
       environment is changed to value.  The string pointed to by string becomes
       part of the environment, so altering the string changes the environment.
  

我相信在 Win32 上它被称为 _putenv 。

See 设置环境变量 http://msdn.microsoft.com/en-us/library/ms686206.aspx另外,如果您喜欢又长又难看的函数名称。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在C++中设置本地环境变量 的相关文章

随机推荐