How to get the System environment variables using MFC API?

Hi,
    We need to get the system CLASSPATH in our Application. Is there any API to get it?
    The GetEnvironmentVariable() method is giving only user variables, but not the system enironment variables.
    One more question: We have used the RegEnumValue to get the registry values from HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\SessionManager\EnvironmentClassapth. But it is returning only some values, but not all the values. What could be the reason?

Please reply as soon as possible as it is very urgent for us.
Thanks in advance
Madhura
Madhura122398Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gus012498Commented:
You could use the
char *getenv( const char *varname );

function.

Regards, Gus
0
ZoppoCommented:
Hi Madhura,

Could you post the code where you read the registry using RegEnumValues?

ZOPPO
0
sumant032199Commented:
You have two ways
1> Use
    char *getenv(const char *str);
where *str is name of environmental variable. Return type is actual value

2> Using an array environ[i] for all the enviromental variables. You can use
while(environ[i]) {     }
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Gus012498Commented:
Its a good idea to suggest my comment as an answer.
0
Madhura122398Author Commented:
Thank you very much. It worked perfectly.
0
sumant032199Commented:
For Gus,
Sorry yaar, My idea was not to copy your answer, but what can I do if we know the same thing. As there is no other answer I was compelled to give it.
And one more thing I have added one more point not only yours.

For Madhura.
Thanks for your assessment.
If you do not mind may I know something about you. I guess you are Indian and also Maharashtrian. Will you please add something in your profile?
I stay at Bombay. (Dombivli)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.