Einzelnen Beitrag anzeigen

delphis spassbremse

Registriert seit: 7. Jun 2007
Ort: Enger
104 Beiträge
 
Delphi 7 Enterprise
 
#3

Re: .exe per Delphi starten und ProzessID aufzeichen

  Alt 30. Jun 2007, 03:29
Jo danke für die Links...

Bei weiteren recherchen hab ich ein bisl code gefunden,
den ich ein bisl angepasst habe...

Wenn´s jemanden interessiert, hier ist der Code xD

Delphi-Quellcode:
function StartExe(FileName: string; Visibility: Integer): Integer;
var { by Pat Ritchey }
  zAppName: array[0..512] of Char;
  zCurDir: array[0..255] of Char;
  WorkDir: string;
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
begin
  StrPCopy(zAppName, FileName);
  GetDir(0, WorkDir);
  StrPCopy(zCurDir, WorkDir);
  FillChar(StartupInfo, SizeOf(StartupInfo), #0);
  StartupInfo.cb := SizeOf(StartupInfo);
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  CreateProcess(nil,
    zAppName, // pointer to command line string
    nil, // pointer to process security attributes
    nil, // pointer to thread security attributes
    False, // handle inheritance flag
    CREATE_NEW_CONSOLE or // creation flags
    NORMAL_PRIORITY_CLASS,
    nil, //pointer to new environment block
    nil, // pointer to current directory name
    StartupInfo, // pointer to STARTUPINFO
    ProcessInfo); // pointer to PROCESS_INF
    result := ProcessInfo.dwProcessId;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  prozessid: Integer;
begin
   prozessid := StartExe('notepad', 1);
   edit1.Text := inttostr(prozessid);
end;
vllt. kann ja jemand was damit anfangen...

MFG

Björn
  Mit Zitat antworten Zitat