Archived

This topic is now archived and is closed to further replies.

encom

SetEnvironmentVariable

Recommended Posts

encom    122
Hi On windows (nt/xp/2k, how to add a directory to PATH env variable ? When i use : char *env = toString("%s:%s", GetEnvironmentStrings("PATH") + "myPath"); SetEnvironmentVariable("PATH", env); Before setEnv, i can use system(..) funtion to call "CMD", after setEnv i can not ! Why ?

Share this post


Link to post
Share on other sites
Oluseyi    2103
Because you fucked up the path. GetEnvironmentString returns a void pointer to an environment block, not a string. Read

Furthermore, you can''t add two C-style strings together using the + operator. Use sprintf.

Share this post


Link to post
Share on other sites