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/)
-   -   Wieso startet UAC minimiert? (https://www.delphipraxis.net/164009-wieso-startet-uac-minimiert.html)

QuickAndDirty 25. Okt 2011 11:04

Wieso startet UAC minimiert?
 
Hi,
habe eine Funktion die wir in diesem Thread http://www.delphipraxis.net/1115750-post27.html entwickelt haben leicht modifiziert,
um eine Anwednung mit Adminrechten zu starten.

Szenario: sfx.exe soll setup.exe mit Adminrechten starten.
Ergebnis: Auf Vista kommt dann auch die UAC auf...leider aber nur minimiert...ich muss die UAC erst in der Taskleiste anklicken bevor sie den bildschirm abdunkelt und dann nach den bestätigen das Setup startet.

Ich will nicht das die UAC minimiert startet! Wie bekomme ich das ordentlich hin?


Hier der verwendete Code zum Starten:
Delphi-Quellcode:
function ExecAndWait(Filename, Params: string; WindowState: word = SW_SHOWNORMAL; const AdminMode:Boolean = true): boolean;
var
  ShExecInfo: SHELLEXECUTEINFO;
  r : Cardinal;
  const
  SEE_MASK_NOASYNC= $100;
begin
  Result := false;
  if Filename = '' then
    exit;
  if not FileExists(FileName) then
  Begin
    ShowMessage('Datei "' + Filename + '" nicht existent!');
    Exit;
  End;
  ZeroMemory(@ShExecInfo, SizeOf(ShExecInfo));
  ShExecInfo.Wnd := application.Handle;
  ShExecInfo.cbSize := sizeof(SHELLEXECUTEINFO);
  ShExecInfo.fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_NOASYNC;
  if AdminMode then
    ShExecInfo.lpVerb := 'runas'
  else
    ShExecInfo.lpVerb := 'open';
  ShExecInfo.lpFile := PChar(Filename);
  ShExecInfo.lpParameters := PChar(Params);
  ShExecInfo.lpDirectory := PChar(ExtractFileDir(Filename));
  ShExecInfo.nShow := WindowState;
  Result := ShellExecuteEx(@ShExecInfo);
  if Result then
  begin
    repeat
      R := MsgWaitForMultipleObjects(1, ShExecInfo.hProcess, False, INFINITE,QS_ALLINPUT);
      if r <> WAIT_OBJECT_0 then
        Application.ProcessMessages;
    until r = WAIT_OBJECT_0;
    CloseHandle(ShExecInfo.hProcess);
  end
  else
    Showmessage('Fehler beim Starten der Anwendung:' + Filename +
                 #13#10'System Fehler: ' + SysErrorMessage(GetLastError));
end;

QuickAndDirty 25. Okt 2011 11:23

AW: Wieso startet UAC minimiert?
 
Hm, das hier war die Lösung...
http://www.delphipraxis.net/92081-fr...llexecute.html

Diese Zeile ist z uändern gewesen

von

Delphi-Quellcode:
  ShExecInfo.Wnd := application.handle;
auf

Delphi-Quellcode:
  ShExecInfo.Wnd := application.MainFormHandle;


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