Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi WinExec32AndWait nicht einbaubar... (https://www.delphipraxis.net/16746-winexec32andwait-nicht-einbaubar.html)

DRPEnc 22. Feb 2004 19:41


WinExec32AndWait nicht einbaubar...
 
Ich will ein Programm durch mein Programm starten. Mit ShellExecute gehts nicht. Nun wollte ich die Funktion WinExec32AndWait ausprobieren und kann diese aber nicht einbauen. Hab ich was bei uses vergessen?

Delphi-Quellcode:
var
  Form6: TForm6;

implementation

uses D2V, AVAENC, ShellAPI;

{$R *.dfm}
Delphi-Quellcode:
procedure TForm6.GroupBox3Click(Sender: TObject);
var ChildExitCode: Cardinal;
begin
  //ChildExitCode := WinExec32AndWait('"C:\DRPEncFiles\DVD2AVIDRPEnc.exe"', SW_NORMAL);
  if ChildExitCode = $FFFFFFFF then
     ShowMessage('Delphi 6 konnte nicht gestartet werden.');
end;
//ExecuteFile('', '', '', False);


function WinExec32AndWait(const Cmd: string; const CmdShow: Integer): Cardinal;
var
  sui : TStartupInfo;
  pi : TProcessInformation;
begin
  Result := Cardinal($FFFFFFFF);
  ZeroMemory(@sui,sizeof(TStartupInfo)); sui.cb := SizeOf(TStartupInfo);
                                         sui.dwFlags := STARTF_USESHOWWINDOW;
                                         sui.wShowWindow := CmdShow;

  if(CreateProcess(nil,pchar(Cmd),nil,nil,False,NORMAL_PRIORITY_CLASS,nil,nil,sui,pi)) then
    begin
      WaitForInputIdle(pi.hProcess, INFINITE);
      if(WaitForSingleObject(pi.hProcess, INFINITE) = WAIT_OBJECT_0) then
        begin
          {$IFDEF DELPHI3}
          if not GetExitCodeProcess(pi.hProcess, Integer(Result)) then
          {$ELSE}
          if not GetExitCodeProcess(pi.hProcess, Result) then
          {$ENDIF DELPHI3}
            Result := Cardinal($FFFFFFFF);
        end;
      CloseHandle(pi.hThread);
      CloseHandle(pi.hProcess);
    end;
end;

DRPEnc 22. Feb 2004 19:43

Re: WinExec32AndWait nicht einbaubar...
 
Lol ... Ich musste es einfach umdrehen in:



Delphi-Quellcode:
function WinExec32AndWait(const Cmd: string; const CmdShow: Integer): Cardinal;
var
  sui : TStartupInfo;
  pi : TProcessInformation;
begin
  Result := Cardinal($FFFFFFFF);
  ZeroMemory(@sui,sizeof(TStartupInfo)); sui.cb := SizeOf(TStartupInfo);
                                         sui.dwFlags := STARTF_USESHOWWINDOW;
                                         sui.wShowWindow := CmdShow;

  if(CreateProcess(nil,pchar(Cmd),nil,nil,False,NORMAL_PRIORITY_CLASS,nil,nil,sui,pi)) then
    begin
      WaitForInputIdle(pi.hProcess, INFINITE);
      if(WaitForSingleObject(pi.hProcess, INFINITE) = WAIT_OBJECT_0) then
        begin
          {$IFDEF DELPHI3}
          if not GetExitCodeProcess(pi.hProcess, Integer(Result)) then
          {$ELSE}
          if not GetExitCodeProcess(pi.hProcess, Result) then
          {$ENDIF DELPHI3}
            Result := Cardinal($FFFFFFFF);
        end;
      CloseHandle(pi.hThread);
      CloseHandle(pi.hProcess);
    end;
end;

procedure TForm6.GroupBox3Click(Sender: TObject);
var ChildExitCode: Cardinal;
begin
  ChildExitCode := WinExec32AndWait('"C:\DRPEncFiles\DVD2AVIDRPEnc.exe"', SW_NORMAL);
  if ChildExitCode = $FFFFFFFF then
     ShowMessage('Delphi 6 konnte nicht gestartet werden.');
end;
... Programm startet aber immer noch nicht... :wall:

DRPEnc 22. Feb 2004 20:23

Re: WinExec32AndWait nicht einbaubar...
 
Problem gelöst ... http://www.delphipraxis.com/topic189...ht=exe+starten


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:36 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