Einzelnen Beitrag anzeigen

hathor
(Gast)

n/a Beiträge
 
#117

AW: Manifest-Creator

  Alt 10. Nov 2013, 13:01
Mit level="requireAdministrator" und WIN 8.0 funktioniert es sehr gut -
VIELEN DANK!

Eine Frage habe ich:
Wenn ein bereits gestartetes Programm minimiert ist und mit folgendem Code wieder angezeigt wird, statt es zum 2.Mal zu starten, ist es eigentlich unnötig, dass die Benutzerkontensteuerung aufpoppt - lässt sich das ändern?

Delphi-Quellcode:
program MyProg;

uses
  Forms, Windows, SysUtils,
  Unit1 in 'Unit1.pas{Form1};

{$R *.res}

procedure SwitchToThisWindow(h1: hWnd; x: bool); stdcall; external user32 Name
'SwitchToThisWindow'; {x = false: Size unchanged, x = true: normal size}

var
  hMutex: Cardinal;
  PreviousHandle : THandle;

BEGIN
  hMutex := CreateMutex(nil, True, PChar(UpperCase(ExtractFileName(ParamStr(0)))));
  if GetLastError = ERROR_ALREADY_EXISTS then
  begin
  PreviousHandle := Windows.FindWindow(NIL,PChar(UpperCase(ExtractFileName(ParamStr(0)))));
    if Windows.IsIconic(PreviousHandle) then
                Windows.ShowWindow(PreviousHandle, SW_RESTORE);
    SwitchToThisWindow(PreviousHandle, TRUE);
    SetForegroundWindow(PreviousHandle);
    SetWindowPos(PreviousHandle,
                HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_SHOWWINDOW);
  end else
  begin
    Application.Initialize;
    Application.MainFormOnTaskbar := True;
    Application.CreateForm(TForm1, Form1);
    Application.Run;
  end;
end.
  Mit Zitat antworten Zitat