• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1059
  • Last Modified:

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
0
Madhura122398
Asked:
Madhura122398
1 Solution
 
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
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
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

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now