uses ShellApi, FileCtrl;
const
EigeneDateien: PChar = nil;
Arbeitsplatz: PChar = '';
function explorer(flr: pchar): boolean;
var
win: string;
begin
result := false;
setlength(win, max_path);
if (flr = nil) or (flr^ = '') or directoryexists(flr) then begin
setlength(win, getwindowsdirectory(pchar(win), max_path));
if ansilastchar(win) <> '\' then win := win + '\';
win := win + 'explorer.exe';
if fileexists(win) then begin
if flr <> nil then flr := pchar('/e,' + flr);
result := shellexecute(0, 'open', pchar(win),
flr, nil, SW_RESTORE) > 32;
end;
end;
setlength(win, 0);
end;
// drei Beispielaufrufe
procedure TForm1.Button3Click(Sender: TObject);
begin
if not explorer(Arbeitsplatz)
then showmessage('Fehler');
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if not explorer('C:\Programme\Microsoft Office')
then showmessage('Fehler');
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if not explorer(EigeneDateien)
then showmessage('Fehler');
end;