Einzelnen Beitrag anzeigen

Benutzerbild von ATS3788
ATS3788

Registriert seit: 18. Mär 2004
Ort: Kriftel
646 Beiträge
 
Delphi XE Starter
 
#4

AW: ShellExecuteEx -> dcc32.exe

  Alt 31. Mai 2013, 13:07
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;
Martin MIchael
  Mit Zitat antworten Zitat