Danke für den Tip. Ich hab noch ein bisschen weiter gesucht und folgendes zusammengeschrieben, was mir die Lösung bringt:
Delphi-Quellcode:
procedure Processandwait(Executable : String);
var
AProcess1: TProcess;
AStringList: TStringList;
AMemo: TMemo;
Result, AString1, AString2 : String;
i : integer;
begin
AStringList := TStringList.Create;
AMemo := TMemo.Create(Form1);
Result:=' ';
try
AProcess1 := TProcess.Create(nil);
AProcess1.CommandLine := Executable;
AProcess1.Options := AProcess1.Options+ [poUsePipes];
{Execute}
AProcess1.Execute;
{Wait to finish}
while AProcess1.running = true do
begin
AStringList.LoadFromStream(AProcess1.Output);
AMemo.lines.add(Astringlist.text);
end;
finally
// Fill Keyboard Models
if Processcmd = 'xkeyboard-models' then
begin
for i := 0 to AMemo.Lines.Count - 1 do
if AMemo.lines[i] = '' then
// do nothing
else
Form1.Page2Combobox.items.add(AMemo.lines[i]);
end;
// Fill Keyboard Layouts
if Processcmd = 'xkeyboard-layouts' then
begin
for i := 0 to AMemo.Lines.Count - 1 do
if AMemo.lines[i] = '' then
// do nothing
else
begin
Astring1:=copy(AMemo.lines[i],0,pos(' ',AMemo.lines[i])-1);
AString2:=copy(AMemo.lines[i],pos(' ',AMemo.lines[i])+1,length(AMemo.lines[i]));
Form1.Page2Layoutlist.items.add(trim(Astring2) + ' (' + Astring1 + ')');
end;
end;
//Clean up;
AProcess1.Free;
AStringlist.Free;
AMemo.Free;
end;
end;
Ergebnis ist nun wie folgt:
Screenshot
Nächste Aufgabe ist aus:
Code:
crh uz: Crimean Tatar (Turkish Q)
crh_f uz: Crimean Tatar (Turkish F)
crh_alt uz: Crimean Tatar (Turkish Alt-Q)
kr104 kr: 101/104 key Compatible
uz: finden und folgende Ausgabe hinzubekommen:
Code:
Crimean Tatar (Turkish F) [crh_f]
Crimean Tatar (Turkish Alt-Q) [crh_alt]