Kleine Nachlieferung auf Nachfrage:
Delphi-Quellcode:
function FindCommand(const command: string): string;
var
i: Integer;
cmd: string;
s: TStrings;
buf: array [0..MAX_PATH] of Char;
begin
s := TStringList.Create;
s.Delimiter := ';';
s.DelimitedText := ExtractFileExt(command);
if s.Count = 0 then
s.DelimitedText := GetEnvironmentVariable('PATHEXT');
Result := ExpandEnvStr(command);
for i := 0 to Pred(s.Count) do
begin
cmd := ChangeFileExt(Result, s[i]);
Move(cmd[1], buf, Succ(Length(cmd)));
if PathFindOnPath(buf, nil) then
begin
Result := buf;
Break;
end;
end;
s.Free;
end;