putenv/setenv using substitutions
Posted
by vinaym
on Stack Overflow
See other posts from Stack Overflow
or by vinaym
Published on 2010-04-17T19:41:42Z
Indexed on
2010/04/17
19:43 UTC
Read the original article
Hit count: 370
c
I need user to define all the environment variables needed for my program in a text file as shown below.
MyDLLPath = C:\MyDLLPath
MyOption = Option1
PATH = %MyDLLPath%;%PATH%;
In my program I read each line and call putenv with the string. Problem is that the environment substitutions (%MyDLLPath%) are not being expanded. I am guessing the following fix for that
- Check each line for % characters.
- Get the text between 2 consecutive % characters.
- Call getenv using the text
- Replace value obtained above into the line and then call putenv.
Is there a better way to do it?
© Stack Overflow or respective owner