PDA

View Full Version : Problen with add system environment.



Flake
6th September 2007, 12:26
Hi all. Sorry for my English. English is not their native language.

I am having a problem when adds system environment on Windows.

Example from the Assistant don't work:


QProcess process;
QStringList env = QProcess::systemEnvironment();
env << "TMPDIR=C:\\MyApp\\temp"; // Add an environment variable
env.replaceInStrings(QRegExp("^PATH=(.*)", Qt::CaseInsensitive), "PATH=\\1;C:\\Bin");
process.setEnvironment(env);
process.start("myapp");

Does anyone have any idea about what is happening?
Thanks.

jpn
6th September 2007, 12:35
What do you mean with "does not work"? QProcess::setEnvironment() sets the environment of that particular process. It does not affect system environment.

Flake
6th September 2007, 12:41
Ok. Can you give me please example of code which add system environment.

marcel
6th September 2007, 13:05
I guess you'll have to use the API on whichever platform you use.
There's no support in Qt for this=.


Regards.

wysota
6th September 2007, 14:12
Is it possible at all? One process shouldn't be able to change the environment of another process, this would violate system security.