Delphi-Quellcode:
var Environment := TStringList.Create;
Environment.TrailingLineBreak := True;
Environment.LineBreak := #0;
//Environment.StrictDelimiter := True;
//Environment.Delimiter := #0;
//Environment.DelimitedText := GetEnvironmentStrings;
var P := GetEnvironmentStrings;
var S: String;
while P <> '' do begin
Environment.Add(P);
Inc(P, Succ(Length(P)));
end;
Environment.Values['PATH'] := Environment.Values['PATH'] + ';' + TPath.Combine(TPath.GetAppPath, 'Version_1.0.0');
var Test := Environment.Text;
//CreateProcess(ApplicationName, CommandLine, ProcessAttributes, ThreadAttributes, InheritHandles, CreationFlags, PChar(Environment.Text), CurrentDirectory, StartupInfo, ProcessInformation);
Well, that is nice !
Alas, i can't repeat it on my XE8, and neither it will work on older versions.
On side note: Environment.Text should add an extra null char (two zeros bytes when used with CreateProcess), so it should be PChar(Environment.Text + #0), of course assuming the last line has the null terminator, if not then it should be added also, and that honestly because i never used StringList with #0 as LineBreak, it gives me goosebumps.