| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 805 人关注过本帖
标题:头痛,如何设置系统的环境变量?
只看楼主 加入收藏
taiw
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-5-27
收藏
 问题点数:0 回复次数:2 
头痛,如何设置系统的环境变量?
我想改变系统的一个环境变量,用putenv只能改变当前程序副本的环境变量,对系统的不起作用。还有什么方法可以直接更改系统的环境变量,可以让其他程序调用?
搜索更多相关主题的帖子: 环境变量 头痛 系统 设置 
2008-05-27 18:06
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:0 
好像不行吧……

专心编程………
飞燕算法初级群:3996098
我的Blog
2008-05-27 18:28
StarWing83
Rank: 8Rank: 8
来 自:仙女座大星云
等 级:贵宾
威 望:19
帖 子:3951
专家分:748
注 册:2007-11-16
收藏
得分:0 
CSDN好像有个帖子,答案是:使用SDK API……

贴一段资料,来源:MSDN
Environment Variables
Every process has an environment block that contains a set of environment variables and their values. The command processor provides the set command to display its environment block or to create new environment variables. Programs started by the command processor inherit the command processor's environment variables.


By default, a child process inherits the environment variables of its parent process. However, you can specify a different environment for the child process by creating a new environment block and passing a pointer to it as a parameter to the CreateProcess function.

The GetEnvironmentStrings function returns a pointer to the environment block of the calling process. This should be treated as a read-only block; do not modify it directly. Instead, use the SetEnvironmentVariable function to change an environment variable. When you are finished with the environment block obtained from GetEnvironmentStrings, call the FreeEnvironmentStrings function to free the block.

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. Note that environment variables listed in this key are limited to 1024 characters.

The GetEnvironmentVariable function determines whether a specified variable is defined in the environment of the calling process, and, if so, what its value is.

For more information, see the examples in Changing Environment Variables.

[[it] 本帖最后由 StarWing83 于 2008-5-27 18:32 编辑 [/it]]

专心编程………
飞燕算法初级群:3996098
我的Blog
2008-05-27 18:29
快速回复:头痛,如何设置系统的环境变量?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016695 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved