About getenv(): 
Author Message
 About getenv():

Hi,all:
 CString Desktop=getenv("USERPROFILE");
When executing this statement,the result is Desktop=="".Do you know why?
Where is the environment variable?


Fri, 04 Mar 2005 16:07:36 GMT  
 About getenv():
Hi Scott,

If you mean why your code can not get the USERPROFILE enviroment variable
as expected,
you can try the following code:

char *Desktop=0;
   /* Get the value of the  USERPROFILE environment variable. */
   Desktop = getenv( "USERPROFILE" );

   if( Desktop != NULL )
          printf( "Original LIB variable is: %s\n", Desktop);

Justin

This posting is provided "AS IS" with no warranties, and confers no rights.



Fri, 04 Mar 2005 21:21:48 GMT  
 About getenv():


Quote:
> Hi,all:
>  CString Desktop=getenv("USERPROFILE");
> When executing this statement,the result is Desktop=="".Do you know why?
> Where is the environment variable?

Works fine for me. I can think of a couple of things,
but details require feedback from you.

- you could be running on an OS that doesn't
    set a USERPROFILE variable (9x)
- you could be running this code in a service
    that runs as the system account, or other
    account that doesn't set a valid user profile
    directory

If none of these possibilities is correct, post again,
this time providing all the details needed to answer
your question.

For tips on creating a post, read How to get help

http://home.att.net/~raffles1/how_to_get_help.htm



Sat, 05 Mar 2005 00:42:03 GMT  
 About getenv():


Quote:



>> Hi,all:
>>  CString Desktop=getenv("USERPROFILE");
>> When executing this statement,the result is Desktop=="".Do you know why?
>> Where is the environment variable?

> Works fine for me. I can think of a couple of things,
> but details require feedback from you.

> - you could be running on an OS that doesn't
>     set a USERPROFILE variable (9x)
> - you could be running this code in a service
>     that runs as the system account, or other
>     account that doesn't set a valid user profile
>     directory

> If none of these possibilities is correct, post again,
> this time providing all the details needed to answer
> your question.

> For tips on creating a post, read How to get help

> http://home.att.net/~raffles1/how_to_get_help.htm

Hi,Ron Ruble
 I'm running on win98 OS.Then,where are the environment variables? Could
you tell me?


Sat, 05 Mar 2005 09:40:13 GMT  
 About getenv():
on the win98 os, environment variables come from several places.
1, system file, where you can not access directly.
2,c:\msdos.sys: windir/winbootdir...
   c:\config.sys: comspec...
   c:\autoexec.bat: tmp/temp/path/prompt....

system provides initial values of environment variables. as a result, if
there is nothing in the config.sys and autoexec.bat, your OS has still
environment variables.

because these system files are protected and OS don't  allow you modify
them to edit environment variables, you need not care about the system
files.

the values in config.sys and autoexec.bat can overwrite the initial
environment variables from system.  in order to set your variables, you
just simple write them in your autoexec.bat or config.sys.

This posting is provided "AS IS" with no warranties, and confers no rights.



Sat, 05 Mar 2005 17:35:12 GMT  
 About getenv():


Quote:


<snip>

> Hi,Ron Ruble
>  I'm running on win98 OS.Then,where are the environment variables? Could
> you tell me?

Go to the command prompt, type

SET

and they will be displayed. For a permanent list, type

SET > C:\env.txt

and a file called env.txt will be created in C:\

This may contain variables specific to your machine.
 For reasons of legacy compatibility, 9x versions
of Windows have very small reserved space for
environment variables, and only a relatively few
are set by default.



Sun, 06 Mar 2005 04:48:19 GMT  
 About getenv():


Quote:





> <snip>

>> Hi,Ron Ruble
>>  I'm running on win98 OS.Then,where are the environment variables? Could
>> you tell me?

> Go to the command prompt, type

> SET

> and they will be displayed. For a permanent list, type

> SET > C:\env.txt

> and a file called env.txt will be created in C:\

> This may contain variables specific to your machine.
>  For reasons of legacy compatibility, 9x versions
> of Windows have very small reserved space for
> environment variables, and only a relatively few
> are set by default.

Hi,Ron Ruble
 Your solutions are good.Do you know if can it executes under win2000 or
win xp OS?


Sun, 06 Mar 2005 16:59:22 GMT  
 About getenv():
of course.
Quote:
>Hi,Ron Ruble
> Your solutions are good.Do you know if can it executes
under win2000 or
>win xp OS?
>.



Sun, 06 Mar 2005 23:11:54 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. getenv and array question

2. "getenv"

3. GETENV no longer supported

4. getenv()

5. getenv q2

6. getenv() question

7. getenv() causing problems

8. gcc bug w/getenv? (running Linux)

9. putenv & getenv

10. getenv()

11. Help with using getenv to access environment variables

12. getenv opposite

 

 
Powered by phpBB® Forum Software