AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi Selbst entpackendes Archiv auspacken
Thema durchsuchen
Ansicht
Themen-Optionen

Selbst entpackendes Archiv auspacken

Ein Thema von zeras · begonnen am 16. Dez 2013 · letzter Beitrag vom 17. Dez 2013
 
zeras

Registriert seit: 11. Mär 2007
Ort: Saalkreis
1.654 Beiträge
 
Delphi 12 Athens
 
#3

AW: Selbst entpackendes Archiv auspacken

  Alt 16. Dez 2013, 19:19
Und wie versuchst du es?
ShellExecuteAndWait(Application.Handle, 'open', PChar(fName), NIL, Nil, SW_SHOW, True); bzw.


Delphi-Quellcode:
Function ExecAndWait(Filename, Params: String;
                     WindowState: Word = SW_SHOWNORMAL): boolean;

var
  {$IFDEF UNICODE} ShExecInfoW: SHELLEXECUTEINFOW; {$ENDIF}
  ShExecInfoA: SHELLEXECUTEINFOA;
// MSDN: ShellExecuteEx, ShellExecuteInfo
  Win32IsUnicode : Boolean;

begin
  Result := false;

  Win32IsUnicode := False;

  if (Filename = '') {or not FileExists(FileName)} then
    exit;
  {$IFDEF UNICODE}
  if Win32IsUnicode then
  begin
    ShExecInfoW.Wnd := GetForegroundWindow;
    ShExecInfoW.cbSize := SizeOf(SHELLEXECUTEINFOW);
    ShExecInfoW.fMask := SEE_MASK_NOCLOSEPROCESS;
    ShExecInfoW.lpVerb := 'open';
    ShExecInfoW.lpFile := PWideChar(WideString(Filename));
    ShExecInfoW.lpParameters := PWideChar(WideString(Params));
    ShExecInfoW.lpDirectory := PWideChar(WideString(ExtractFileDir(Filename)));
    ShExecInfoW.nShow := WindowState;
    Result := ShellExecuteExW(@ShExecInfoW);
    try
      if Result then WaitForSingleObject(ShExecInfoW.hProcess, INFINITE);
    finally
      CloseHandle(ShExecInfoW.hProcess);
    end;
  end
  else
  {$ENDIF}
  begin
    ShExecInfoA.Wnd := GetForegroundWindow;
    ShExecInfoA.cbSize := sizeof(SHELLEXECUTEINFOA);
    ShExecInfoA.fMask := SEE_MASK_NOCLOSEPROCESS;
    ShExecInfoA.lpVerb := 'open';
    ShExecInfoA.lpFile := PAnsiChar(AnsiString(Filename));
    ShExecInfoA.lpParameters := PAnsiChar(AnsiString(Params));
    ShExecInfoA.lpDirectory := PAnsiChar(AnsiString(ExtractFileDir(Filename)));
    ShExecInfoA.nShow := WindowState;
    Result := ShellExecuteExA(@ShExecInfoA);
    try
      if Result then WaitForSingleObject(ShExecInfoA.hProcess, INFINITE);
    finally
      CloseHandle(ShExecInfoA.hProcess);
    end;
  end;
end;
Matthias
Es ist nie falsch das Richtige zu tun!
- Mark Twain
  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 00:06 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