Jump to content
  • Advertisement
Sign in to follow this  
derek7

when is environment variable created?

This topic is 4807 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

the environmentvariable in vc is equal environmentvariable in windows?? for example path variable in windows and $(VSInstallDir) in vc can be access by GetEnvironmentVariable SetEnvironmentVariable? when was these environment variable created? where was thes environment variable created? are these global? what is different from variable created by programmer self. like int var1; float var2;

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by derek7
the environmentvariable in vc is equal environmentvariable in windows??
Yes

Quote:
Original post by derek7
for example path variable in windows and $(VSInstallDir) in vc can be access
by GetEnvironmentVariable SetEnvironmentVariable?
Yes

Quote:
Original post by derek7
when was these environment variable created?
where was thes environment variable created?
are these global?
They were created (registered) when the program that set them was installed. For instance, the $(VSInstallDir) variable would be registered when you installed VS, and the PATH variable when you installed windows (And other applications might change it). They're system-wide, yes.

Quote:
Original post by derek7
what is different from variable created by programmer self.
like int var1; float var2;
An environment variable is a variable that is global to Windows. Any application can read/write it. An environment variable is a key-value type, where both types are strings - I.e. you can't store an int in an environment variable (Well, you can store the string representation of it like "42").


Edit: You can use this code to list all the environment variables:

void* pEnvironmentStrings = GetEnvironmentStrings();
char* psz = (char*)pEnvironmentStrings;
do {
OutputDebugString(psz);
OutputDebugString("\n");
psz += strlen(psz)+1;
} while(*psz);
FreeEnvironmentStrings((LPSTR)pEnvironmentStrings);



Share this post


Link to post
Share on other sites
thank for your clear explanation.but one thing I don't know .

these environment variables are defined at system boot time?

when I setup windows or vc,every time system boot,these variables are defined at memory??
and which memory segment are these variable defined?
on heap? on stack? or .............

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!