[Lazarus] SetEnv on Linux 64bit

Andrew Haines AndrewD207 at aol.com
Wed Apr 4 00:12:08 CEST 2012


On 04/03/12 11:04, fred f wrote:
> Hi guys,
> 
> I try to start itself again with this code, but it doesn't work:
> 
>   IF GetEnvironmentVariable('LIBOVERLAY_SCROLLBAR') <> '0' THEN begin
>     mProc := TProcess.Create(NIL);
>     mProc.CommandLine := GetExeName;
>     mProc.Environment.Add('LIBOVERLAY_SCROLLBAR=0');
>     mProc.Environment.Add('UBUNTU_MENUPROXY=');
>     mProc.Options := mProc.Options + [poNoConsole];
>     mProc.Execute;
>     mProc.Free;
> 
>     halt; //close itself
>   END;
> 
> What's wrong with this code?
> 
> Tnx, f.
> 

I'm can't say for sure that this is your problem but in the past I have
observed that TProcess dumps all the inherited environment vairables as
soon as you add something to it. On linux this means that the DISPLAY
environment variable is not set.

You'll need something like this:

for i := 0 to GetEnvironmentVariableCount-1 do
begin
   EnvVarName := GetEnvironmentString(i);
   EnvVarValue := GetEnvironmentVariable(EnvVarName);
   mProc.Environment.Add(EnvVarName+'='+EnvVarValue);
end;
mProc.Environment.Add('LIBOVERLAY_SCROLLBAR=0');

Regards,

Andrew Haines




More information about the Lazarus mailing list