Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi CreateProcess Verknüpfte Dateien öffnen (https://www.delphipraxis.net/136740-createprocess-verknuepfte-dateien-oeffnen.html)

schwa226 7. Jul 2009 07:05


CreateProcess Verknüpfte Dateien öffnen
 
Hi,

ich starte externe Programme mit dieser Funktion:
Delphi-Quellcode:
function RunProcess(FileName: string; ShowCmd: DWORD; wait: Boolean; ProcIDRunProcess: PDWORD): TProcessInformation;
type
  TDWordList = Array of DWord;

var
  StartupInfoRunProcess: TStartupInfoA;
  ProcessInfoRunProcess: TProcessInformation;
begin
  FillChar(StartupInfoRunProcess, SizeOf(StartupInfoRunProcess), #0);
  StartupInfoRunProcess.cb         := SizeOf(StartupInfoRunProcess);
  StartupInfoRunProcess.dwFlags    := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
  StartupInfoRunProcess.wShowWindow := ShowCmd;


  if not CreateProcessA(nil,@Filename[1],nil,nil,False, CREATE_BREAKAWAY_FROM_JOB or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,nil,nil,StartupInfoRunProcess,ProcessInfoRunProcess) then begin
  Result.hProcess := WAIT_FAILED;
  end
  else
  begin
    Result := ProcessInfoRunProcess;

    WaitForInputIdle(ProcessInfoRunProcess.hProcess, 30000);

    if wait = FALSE then
    begin
      //if ProcIDRunProcess <> nil then ProcIDRunProcess^ := ProcessInfoRunProcess.dwProcessId;
      exit;
    end;

    WaitForSingleObject(ProcessInfoRunProcess.hProcess, INFINITE);
    GetExitCodeProcess(ProcessInfoRunProcess.hProcess, Result.hProcess);
  end;

  if ProcessInfoRunProcess.hProcess <> 0 then
    CloseHandle(ProcessInfoRunProcess.hProcess);
  if ProcessInfoRunProcess.hThread <> 0 then
    CloseHandle(ProcessInfoRunProcess.hThread);
end;
Jedoch ist es mir mit dieser nicht Möglich Verknüpfte Dateien (z.B. C:\test.txt) zu öffnen. Brauch ich dazu Shellexecute oder geht das auch direkt mit CreatProcess?

EDIT: Habe es nun mit dieser Funktion zum laufen gebracht:
http://www.delphipraxis.net/internal...002454#1002454

Nun werden z.B. txt-Files im Notepad geöffnet!

Dezipaitor 7. Jul 2009 19:43

Re: CreateProcess Verknüpfte Dateien öffnen
 
Nein, dazu ist ja ShellExecute.


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:03 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz