Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi ShellExecuteEx -> dcc32.exe (https://www.delphipraxis.net/175046-shellexecuteex-dcc32-exe.html)

ATS3788 27. Mai 2013 12:31

ShellExecuteEx -> dcc32.exe
 
Hallo
Ich habe noch nie was mit ShellExecuteEx gemacht nun probiere ich ein wenig rum
und bin auf
http://www.delphipraxis.net/165886-s...x-problem.html
gestossen.

Ich starte eine eine Batch das funktioniert auch gut.

Delphi-Quellcode:
dummyPath := '"' + ExePath + 'RC\MakeResDll.bat' + '"';
iCE:= shellapi.shellExecute(0, 'open', pChar(dummyPath), nil, nil, SW_MAXIMIZE);
Aber schöner wärs schon mit der folgenden function,
ich bekomme auch ein ShellExecuteEx(@Sei) = true hin
nur wird die dll nicht erstellt.

Ich übergebe

FileName = Pfad + dcc32.exe
Directory = Ausgabepfad
Parameter = Pfad von File .dpr
Verb = '' = Nil;
CmdShow = 1;


Delphi-Quellcode:
function ShellExecAndWait(const FileName, Directory, Parameters, Verb: string; CmdShow: Integer): Boolean;
var
   Sei: TShellExecuteInfo;
begin
   FillChar(Sei, SizeOf(Sei), #0);
   Sei.cbSize := SizeOf(Sei);
   Sei.fMask := SEE_MASK_DOENVSUBST or SEE_MASK_FLAG_NO_UI or SEE_MASK_NOCLOSEPROCESS;
   Sei.lpFile := PCharOrNil(FileName);
   Sei.lpDirectory := PCharOrNil(Directory);
   Sei.lpParameters := PCharOrNil(Parameters);
   Sei.lpVerb := PCharOrNil(Verb);
   Sei.nShow := CmdShow;
   Result := ShellExecuteEx(@Sei);
   if Result then
   begin
     WaitForInputIdle(Sei.hProcess, INFINITE);
     WaitForSingleObject(Sei.hProcess, INFINITE);
     CloseHandle(Sei.hProcess);
   end;
end;
Meine Frage gibt es eine Möglichkeit das das cmd Fenster nicht geschlossen wird
um zu sehen was ich falsch mache oder mache ich generell einen Denkfehler

DeddyH 27. Mai 2013 12:42

AW: ShellExecuteEx -> dcc32.exe
 
Schreib als letzte Zeile in die Batch-Datei ein "pause" (ohne Anführungszeichen).

ATS3788 27. Mai 2013 15:31

AW: ShellExecuteEx -> dcc32.exe
 
DeddyH
Das ist nett, nur ich möchte es eben nicht als
Batch ausführen sondern mit ShellExecuteEx,
ich möchte verstehen wie diese function funktioniert mit einem
dcc32 aufruf.

ATS3788 31. Mai 2013 13:07

AW: ShellExecuteEx -> dcc32.exe
 
Eigentlich ganz einfach
Vielleicht nützt es ja mal jemanden

Delphi-Quellcode:
function PCharOrNil(const AString: string): PChar;
begin
   if AString = '' then
      Result := nil
    else
     Result := PChar(AString);
end;

function ShellExecAndWait(const FileName, Directory, Parameters, Verb: string; CmdShow: Integer): Boolean;
var
   SEI: TShellExecuteInfo;
begin
   FillChar(SEI, SizeOf(SEI), #0);
   SEI.cbSize := SizeOf(SEI);
   SEI.fMask := SEE_MASK_DOENVSUBST or SEE_MASK_FLAG_NO_UI or SEE_MASK_NOCLOSEPROCESS;
   SEI.lpFile := PCharOrNil(FileName);    // Filename
   SEI.lpDirectory := PCharOrNil(Directory);        // Directory
   SEI.lpParameters := PCharOrNil(Parameters); //  Parameters
   SEI.lpVerb := PCharOrNil(Verb);      // Verb
   SEI.nShow := CmdShow;         // How display the CMD Window
   Result := ShellExecuteEx(@SEI);
   if Result then
   begin
     WaitForInputIdle(SEI.hProcess, INFINITE);
     WaitForSingleObject(SEI.hProcess, INFINITE);
     CloseHandle(SEI.hProcess);
   end;
end;

procedure TForm1.Button2Click(Sender: TObject);
const
Dcc32Path = 'D:\Users\xyz\Documents\RAD Studio\MyProjects\SetWinIcon\Debug\SetIcon.d\RC\cfg\dcc32.exe';
DprPath   = 'D:\Users\xyz\AppData\Local\Temp\RC\justtest.dpr';
OutPutPath = 'D:\Users\xyz\Pictures';
begin

if ShellExecAndWait(Dcc32Path , OutPutPath , DprPath ,'open', 1) then
self.Color := clGreen
else
self.Color := clFuchsia;
end;


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