uses FileCtrl;
function GetRP(const basis, ziel: string): string;
function bslash(const s: string): string;
begin
result := s;
if ansilastchar(result) <> '\' then result := result + '\';
end;
begin
if (directoryexists(basis)) and (directoryexists(ziel)) then
result := ExtractRelativePath(bslash(basis), bslash(ziel))
else result := '';
end;
// Beispielaufruf
procedure TForm1.Button5Click(Sender: TObject);
var s: string;
begin
s := GetRP('C:\Dokumente und Einstellungen', 'C:\Windows');
if s = '' then showmessage('FEHLER') else
Label1.caption := s;
end;