Einzelnen Beitrag anzeigen

darkmarin

Registriert seit: 26. Sep 2011
23 Beiträge
 
Delphi XE3 Professional
 
#6

AW: Eine *.cmd die startet, aber vorzeitig abbricht!

  Alt 10. Okt 2012, 12:42
Hallo Detlef

wie meinst du das?
Jetzt mal nur ein Aufruf als Beispiel.
Delphi-Quellcode:
begin
  if ExecAndWaitUAC('c:\openocd-0.5.0\bin\openocd-0.5.0.exe', ' -f c:\openocd-0.5.0\interface\jtagkey.cfg -f C:\openocd-0.5.0\WORK\jtag_ertec\ertec200.cfg -c "global SOURCE" -c "set SOURCE 4377FC_105.bin" -f c:/FknFile/4377FC_105.scr > c:\AmoLogFiles\Standard.log');
then
Die Funktion ist nicht von mir sondern lediglich die letzte von vielen die ich ausprobiert habe.

Delphi-Quellcode:
function TspecConsole.ExecAndWaitUAC(Filename, Params: Widestring; WindowState: word = SW_SHOWNORMAL): boolean;
var
  ShExecInfoW: SHELLEXECUTEINFOW;
  ShExecInfoA: SHELLEXECUTEINFOA;
  r : Cardinal;
begin
  Result := false;
  if Filename = 'then exit;
  if not FileExists(FileName) then
    exit;
    ZeroMemory(@ShExecInfoW, SizeOf(ShExecInfoW));
    ShExecInfoW.Wnd := GetForegroundWindow;
    ShExecInfoW.cbSize := sizeof(SHELLEXECUTEINFOW);
    ShExecInfoW.fMask := SEE_MASK_NOCLOSEPROCESS;
    ShExecInfoW.lpVerb := 'open';
    ShExecInfoW.lpFile := PWideChar(Filename);
    ShExecInfoW.lpParameters := PWideChar(Params);
    ShExecInfoW.lpDirectory := PWideChar(ExtractFileDir(Filename));
    ShExecInfoW.nShow := WindowState;
    Result := ShellExecuteExW(@ShExecInfoW);

  try
    if Result then
    begin
      r := WaitForSingleObject(ShExecInfoW.hProcess, INFINITE)
    end;
  finally
    //CloseHandle(ShExecInfoW.hProcess);
  end;
end;
Gruß

Darko
  Mit Zitat antworten Zitat