PDA

View Full Version : Accessing Environment Variables



mhoover
21st September 2006, 01:09
Hi,

I'm trying to find a way of accessing some environment varibles. I thought I saw something somewhere in the docs about it, but I didn't see anything in QApplication.

I hope to get out of doing a QProcess env command and searching through the results.


Thanks!

jacek
21st September 2006, 01:40
How about ::getenv()? It should be implemented even on windows.

wysota
21st September 2006, 02:03
You can also use the third argument to the main() function, just remember you get a copy of environment there.

gfunk
21st September 2006, 02:08
How about ::getenv()? It should be implemented even on windows.

In Windows:
Note: getenv is deprecated; consider using getenv_s instead

You expected MS to break the mold, right? :p

mhoover
21st September 2006, 02:10
Thanks !! getenv works great.

getenv_s must be windows because I can't compile with that command.

fullmetalcoder
21st September 2006, 09:09
You folks are Qt addicts aren't you? So , how about using qgetenv() instead? It provides portability and same features as the classic getenv() ...

Zatraz
21st September 2006, 16:05
The only issue about qgetenv is that it is only defined in Qt version 4.X.