class procedure TEnvironment.GetEnvironmentVariables(list: TStrings); var pEnv: PChar; p: PChar; s: string; begin pEnv := GetEnvironmentStrings; try p := pEnv; list.BeginUpdate; try list.Clear; while p^ <> #0 do begin s := p; if Pos('=', s) > 1 then // Skip when begins with '=' list.Add(s); Inc(p, Length(s) + 1); // Jump to the next variable end; finally list.EndUpdate; end; finally Win32Check(FreeEnvironmentStrings(pEnv)); end; end;