AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Problem ShellExecute / CreateProcess + Wait mit Vista UAC
Thema durchsuchen
Ansicht
Themen-Optionen

Problem ShellExecute / CreateProcess + Wait mit Vista UAC

Ein Thema von Assertor · begonnen am 14. Mai 2007 · letzter Beitrag vom 9. Sep 2011
 
Benutzerbild von sh17
sh17

Registriert seit: 26. Okt 2005
Ort: Radebeul
1.690 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Problem ShellExecute / CreateProcess + Wait mit Vista UA

  Alt 14. Mai 2007, 20:58
Das Sollte helfen:

Delphi-Quellcode:
function ExecAndWait(Filename, Params: Widestring;
                     WindowState: word = SW_SHOWNORMAL): boolean;
 var
  ShExecInfo : SHELLEXECUTEINFOW;
  r : Cardinal;
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecuteex.asp
//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/structures/shellexecuteinfo.asp
begin
  Result := false;
  if Filename = 'then exit;
  if not WideFileExists(FileName) then
  begin
    Log (true,P_ERROR,WideFormat(_('Kann die angegebene Datei nicht finden: %s'),[FileName]));
    exit;
  end;

  ShExecInfo.cbSize := sizeof(SHELLEXECUTEINFOW);
  ShExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS;
  ShExecInfo.lpVerb := 'open';
  ShExecInfo.lpFile := PWideChar(Filename);
  ShExecInfo.lpParameters := PWideChar(Params);
  ShExecInfo.lpDirectory := PWideChar(WideExtractFileDir(Filename));
  ShExecInfo.nShow := WindowState;
  Result := ShellExecuteExW(@ShExecInfo);

  try
    if Result then
    begin
      r := WaitForSingleObject(ShExecInfo.hProcess, INFINITE);
      if r <> WAIT_OBJECT_0 then
        Log(true,P_FATAL,IntToStr(r)+#10+WideFormat(_('Fehler beim Beenden von "%s".'),[Filename]));
    end else
      Log(true,P_FATAL,SysErrorMessage(GetLastError)+#10+WideFormat(_('Fehler beim Starten von "%s".'),[Filename]));
  finally
    CloseHandle(ShExecInfo.hProcess);
  end;
end;
Sven Harazim
--
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:15 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz