The following code lists the environment variables of the current process:
for i := 0 to GetEnvironmentVariableCount-1 do
Log(GetEnvironmentString(i));
The result is something like this:
TMPDIR=/var/folders/mp/gx458m3x0c5__tsxrgcczs880000gn
SHELL=/bin/bash
HOME=/Users/admin
... and several more lines like that
Now, I would like to add one more environmental variable to the list, e.g. MYNAME=my-value
I only want to add this environmental variable to the current running process. This is useful, for example, to pass information to a dylib.(1)
On Windows this can be done with SetEnvironmentVariable() and on Linux, I read, there is SetEnv().
So the question is, how do I do it on MacOS?
I know about the "export" bash command, so I tried to execute the command from within my program, like this:
Uses unix;
fpsystem('export MYNAME=my-value');
After doing that, however, if I use again GetEnvironmentVariableCount() and GetEnvironmentString(i), nothing has changed, my name/value pair is not there.
So, can someone kindly show me how to do it?
(1) I'm asking this question because I'm trying to use the VLC library on MacOS, and before I can call certain functions in the dylib files, I must provide an environment variable named VLC_PLUGIN_PATH containing the full path of the plugins folder.