Thema: Delphi Datei öffnen

Einzelnen Beitrag anzeigen

Benutzerbild von robinWie
robinWie

Registriert seit: 26. Okt 2005
Ort: Lippcity
404 Beiträge
 
Delphi 2005 Personal
 

Re: Datei öffnen

  Alt 5. Dez 2005, 16:14
Ich habe mir mal ne Procedure geschrieben. Du musst noch oben bei uses "ShellApi" eintragen!

Delphi-Quellcode:
procedure TMainForm.ExecuteProgramm(const PFileName: string);
var
  SEInfo: TShellExecuteInfo;
  ExitCode: DWORD;
  ExecuteFile, ParamString, StartInString: string;
begin
  ExecuteFile:=PFileName;
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := Application.Handle;
    lpFile := PChar(ExecuteFile);
    nShow := SW_SHOWNORMAL;
  end;
  if ShellExecuteEx(@SEInfo) then begin
    repeat
      Application.ProcessMessages;
      GetExitCodeProcess(SEInfo.hProcess, ExitCode);
    until (ExitCode <> STILL_ACTIVE) or
      Application.Terminated;
  end
  else begin
  Application.MessageBox('Fehler beim Starten des Programms',
  'Programm Starten',
  mb_OK+mb_IconError);
  end;
end;
Robin W.
Ein Computer kann (fast) alles.... Man muss es ihm nur beibringen
  Mit Zitat antworten Zitat